Welcome to Geeklog, Anonymous Saturday, September 07 2024 @ 08:07 pm EDT
Geeklog Forums
More custom user fun
Once again: Geeklog ROCKS!
Dirk, thanks to your suggestion, I was able to get the custom registration stuff done in about 10 minutes. Great stuff. One snag I did run into was the "batch user load". Appears to be some sort of filesystem permission problem, but I simply added all the users manually. After I did that, however, I could not log in as a user and save a custom profile. The regular user functions worked fine, but none of the custom stuff worked. In anycase, I tracked it down to the Update function in the libcommon.php file.
When I added a user manually, a custom record in the custom table was not created for that user. When a user went to save his updated profile, the code simply does an "update" on both the regular GeekLog user tables AND the custom table. If there is no record in the custom table, it makes it a little hard to update
.
In anycase, I fixed the problem with the following code. I have simply added my entire custom_usersave() function from the lib-common.php file.
function custom_usersave($uid) {
global $_CONF,$_TABLES,$HTTP_POST_VARS;
// Note you will need to ensure all data is prepared correctly before inserts - as quotes may need to be escaped with addslashes()
//JTS: 9/9/2003 Check if the custom table exists first
$result = DB_query("SELECT uid FROM {$_TABLES['custom_memberinfo']} WHERE {$_TABLES['custom_memberinfo']}.uid = $uid"
;
$A = DB_fetchArray($result);
if (strlen($A['uid'])==0)
{
DB_query("INSERT INTO {$_TABLES['custom_memberinfo']} (uid,address,firstname,lastname) VALUES ($uid,'{$HTTP_POST_VARS['address']}','{$HTTP_POST_VARS['firstname']}','{$HTTP_POST_VARS['lastname']}'
"
;
}
else
{
DB_query("UPDATE {$_TABLES['custom_memberinfo']} SET
address='{$HTTP_POST_VARS['address']}',
firstname='{$HTTP_POST_VARS['firstname']}',
lastname='{$HTTP_POST_VARS['lastname']}'
WHERE uid=$uid"
;
}
DB_query("UPDATE {$_TABLES['users']} SET
email='{$HTTP_POST_VARS['email']}',
homepage='{$HTTP_POST_VARS['homepage']}',
fullname='{$HTTP_POST_VARS['firstname']} {$HTTP_POST_VARS['lastname']}'
WHERE uid=$uid"
;
return true;
}
Because I and my users like to live dangerously, I have ignored the "data preparation" warning
. Hope this helps someone.
Dirk, thanks to your suggestion, I was able to get the custom registration stuff done in about 10 minutes. Great stuff. One snag I did run into was the "batch user load". Appears to be some sort of filesystem permission problem, but I simply added all the users manually. After I did that, however, I could not log in as a user and save a custom profile. The regular user functions worked fine, but none of the custom stuff worked. In anycase, I tracked it down to the Update function in the libcommon.php file.
When I added a user manually, a custom record in the custom table was not created for that user. When a user went to save his updated profile, the code simply does an "update" on both the regular GeekLog user tables AND the custom table. If there is no record in the custom table, it makes it a little hard to update
![Smile Smile](https://www.geeklog.net/forum/image_set/pixel.gif)
In anycase, I fixed the problem with the following code. I have simply added my entire custom_usersave() function from the lib-common.php file.
function custom_usersave($uid) {
global $_CONF,$_TABLES,$HTTP_POST_VARS;
// Note you will need to ensure all data is prepared correctly before inserts - as quotes may need to be escaped with addslashes()
//JTS: 9/9/2003 Check if the custom table exists first
$result = DB_query("SELECT uid FROM {$_TABLES['custom_memberinfo']} WHERE {$_TABLES['custom_memberinfo']}.uid = $uid"
![Wink Wink](https://www.geeklog.net/forum/image_set/pixel.gif)
$A = DB_fetchArray($result);
if (strlen($A['uid'])==0)
{
DB_query("INSERT INTO {$_TABLES['custom_memberinfo']} (uid,address,firstname,lastname) VALUES ($uid,'{$HTTP_POST_VARS['address']}','{$HTTP_POST_VARS['firstname']}','{$HTTP_POST_VARS['lastname']}'
![Wink Wink](https://www.geeklog.net/forum/image_set/pixel.gif)
![Wink Wink](https://www.geeklog.net/forum/image_set/pixel.gif)
}
else
{
DB_query("UPDATE {$_TABLES['custom_memberinfo']} SET
address='{$HTTP_POST_VARS['address']}',
firstname='{$HTTP_POST_VARS['firstname']}',
lastname='{$HTTP_POST_VARS['lastname']}'
WHERE uid=$uid"
![Wink Wink](https://www.geeklog.net/forum/image_set/pixel.gif)
}
DB_query("UPDATE {$_TABLES['users']} SET
email='{$HTTP_POST_VARS['email']}',
homepage='{$HTTP_POST_VARS['homepage']}',
fullname='{$HTTP_POST_VARS['firstname']} {$HTTP_POST_VARS['lastname']}'
WHERE uid=$uid"
![Wink Wink](https://www.geeklog.net/forum/image_set/pixel.gif)
return true;
}
Because I and my users like to live dangerously, I have ignored the "data preparation" warning
![Cool Cool](https://www.geeklog.net/forum/image_set/pixel.gif)
8
11
Quote
Status: offline
emagin
Forum User
Regular Poster
Registered: 08/05/03
Posts: 92
Hi JT, could you point me to an example or screenshot of what fields you are using for custom users.
I am interested in having users do firstname lastname phone, etc. and Dirk has pointed me to the custom-lib functions examples. I\'m a little new at PHP so still struggling with it, was hoping to see something that works so I can get ideas of how to fix things I\'ll probably break
Thanks!
10
10
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Quote by jt:When I added a user manually, a custom record in the custom table was not created for that user.
It seems admin/user.php only calls the custom function when an account is deleted but not when a new user is created (manually or from the batch import).
Looks like a bug to me ...
bye, Dirk
11
9
Quote
Status: offline
jt
Forum User
Newbie
Registered: 09/01/03
Posts: 7
Emagin, don\'t know what good a screen shot is going to be to getting the custom user reg setup.
The comment that begins with: \"Sample Custom Member Functions to create and update Custom Membership registration and profile \" has excellent instructions on how to setup the custom user regs, step by step. You just need a little coding experience (not a whole lot...just familiarity with variables) and some patience.
9
14
Quote
All times are EDT. The time is now 08:07 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