Welcome to Geeklog, Anonymous Friday, April 26 2024 @ 04:41 pm EDT

Geeklog Forums

Custom User Registration


Eddy

Anonymous
Thanks for that.

I wonder if anyone else has had any problems with the Custom User Reg Fields not processing when the SUBMIT button is pressed?! I've got my additional fields showing up as I had hoped (almost, but close enough) but when the user presses SUBMIT on the registration form, the details aren't saved and the new registration isn't processed. Does anyone have any ideas as to what could be causing this!?

Thanks
 Quote

Eddy

Anonymous
(Sorry - this was meant to be added to my other thread on this subject)
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
What does your CUSTOM_usersave and CUSTOM_userCheck functions look like?
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Eddy

Anonymous
Quote by: Blaine

What does your CUSTOM_usersave and CUSTOM_userCheck functions look like?



Hi Blaine, usersave looks like this :
Text Formatted Code
/* Function called when saving the user profile. */
function custom_usersave($uid) {
    global $_TABLES;

    $grad_year = COM_applyFilter($_POST['cust_gradyear'],true);
    $position = COM_applyFilter($_POST['cust_position'],true);
    $fleet = COM_applyFilter($_POST['cust_fleet'],true);
    $base = COM_applyFilter($_POST['cust_base'],true);
    $fullname  = COM_applyFilter($_POST['fullname']);

    DB_query("UPDATE {$_TABLES['users']} SET fullname='$fullname' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET position='$position' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET fleet='$fleet' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET base='$base' WHERE uid='$uid'");
    if ($grad_year > 0) {
        DB_query("UPDATE {$_TABLES['localuserinfo']} SET grad_year='$grad_year' WHERE uid='$uid'");
    }

}


And userCheck doesn't appear to be there..... Atleast not in lib_custom.php.

Cheers
 Quote

Eddy

Anonymous
Quote by: Eddy

Quote by: Blaine

What does your CUSTOM_usersave and CUSTOM_userCheck functions look like?



Hi Blaine, usersave looks like this :
Text Formatted Code
/* Function called when saving the user profile. */
function custom_usersave($uid) {
    global $_TABLES;

    $grad_year = COM_applyFilter($_POST['cust_gradyear'],true);
    $position = COM_applyFilter($_POST['cust_position'],true);
    $fleet = COM_applyFilter($_POST['cust_fleet'],true);
    $base = COM_applyFilter($_POST['cust_base'],true);
    $fullname  = COM_applyFilter($_POST['fullname']);

    DB_query("UPDATE {$_TABLES['users']} SET fullname='$fullname' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET position='$position' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET fleet='$fleet' WHERE uid='$uid'");
    DB_query("UPDATE {$_TABLES['localuserinfo']} SET base='$base' WHERE uid='$uid'");
    if ($grad_year > 0) {
        DB_query("UPDATE {$_TABLES['localuserinfo']} SET grad_year='$grad_year' WHERE uid='$uid'");
    }

}


And userCheck doesn't appear to be there..... Atleast not in lib_custom.php.

Cheers


Have now added the following in lib_custom.php

Text Formatted Code
/**
* Check if it's okay to create a new user.
*
* Geeklog is about to create a new user with the given username and email
* address. This is the custom code's last chance to prevent that,
* e.g. to check if all required data has been entered.
*
* @param    string  $username   username that Geeklog would use for the new user* @param    string  $email      email address of that user
* @return   string              an error message or an empty string for "OK"
*
*/
function CUSTOM_userCheck ($username, $email)
{
    $msg = '';

    // Example, check that the full name has been entered
    // and complain if it's missing
    if (empty ($_POST['fullname'])) {
        $msg = 'Please enter your full name!';
    }

    return $msg;
}
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Actually it's the CUSTOM_userCreate function thats is called on registeration to create the new record. The userSave is just doing a save but it also should first check if the user record is there and if not then do an insert.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Eddy

Anonymous
Quote by: Blaine

Actually it's the CUSTOM_userCreate function thats is called on registeration to create the new record. The userSave is just doing a save but it also should first check if the user record is there and if not then do an insert.

Cheers mate. Here's userCreate.
Text Formatted Code
/* Create any new records in additional tables you may have added  */
/* Update any fields in the core GL tables for this user as needed */
/* Called when user is first created */
function custom_usercreate($uid) {
    global $_TABLES;

    $grad_year = COM_applyFilter($_POST['cust_gradyear'],true);
    $fleet = COM_applyFilter($_POST['cust_fleet'],true);
    $position = COM_applyFilter($_POST['cust_position'],true);
    $base = COM_applyFilter($_POST['cust_base'],true);
    $fullname  = COM_applyFilter($_POST['cust_fullname']);

    // Ensure all data is prepared correctly before inserts, quotes may need to be escaped with addslashes()
    DB_query("INSERT INTO {$_TABLES['localuserinfo']} (uid,grad_year) VALUES ('$uid', '$grad_year', '$fleet', '$position', '$base')");
    DB_query("UPDATE {$_TABLES['users']} SET fullname = '$fullname' WHERE uid='$uid'");
    return true;

}
 
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Do you really have a field grad_year in your form - I suspect you don't.

I also expect you are getting a SQL error in your error.log file. The insert SQL stmt describes two fields

"INSERT INTO {$_TABLES['localuserinfo']} (uid,grad_year)

and yet you are passing in five

'$uid', '$grad_year', '$fleet', '$position', '$base'

Also have you created the new table as defined by $_TABLES['localuserinfo'] with the correct structure Confused:
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Eddy

Anonymous
Quote by: Blaine

Do you really have a field grad_year in your form - I suspect you don't.

I also expect you are getting a SQL error in your error.log file. The insert SQL stmt describes two fields


"INSERT INTO {$_TABLES['localuserinfo']} (uid,grad_year)

and yet you are passing in five

'$uid', '$grad_year', '$fleet', '$position', '$base'

Also have you created the new table as defined by $_TABLES['localuserinfo'] with the correct structure Confused:


Hi Blaine,

Thanks for the continued support. What I've done is keep grad_year which was your 'example' and just changed all reference on the forms to read 'staff number' instead. So while it contains a staff number as opposed to a graduation year, I thought it easier to leave the fields/tables as grad_year.

I've added the extra fields in the insert SQL stmt and, as for the table, I'm confident that this is done correctly - I simply copied and amended slightly your own SQL dump from the zip.

I'll give it a bash now I've changed the SQL stmt and see what happens.

Cheers
 Quote

All times are EDT. The time is now 04:41 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content