Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 04:45 am EDT

Geeklog Forums

More custom user fun


Status: offline

jt

Forum User
Newbie
Registered: 09/01/03
Posts: 7
cheerful
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 Smile.

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&quotWink;
$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&quotWink;
}
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&quotWink;
}
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&quotWink;
return true;
}


Because I and my users like to live dangerously, I have ignored the "data preparation" warning Cool . Hope this helps someone.
 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!
 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
 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.
 Quote

All times are EDT. The time is now 04:45 am.

  • 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