Topics

User Functions

Events

There are no upcoming events

What's New

Stories

No new stories

Comments last 2 weeks

No new comments

Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Wednesday, May 22 2013 @ 03:49 AM EDT


 Forum Index > Extensions > Cool Hacks New Topic Post Reply
 More custom user fun
   
jt
 09/10/03 08:06PM (Read 1887 times)  
+----
Newbie
cheerful

Status: offline


Registered: 09/01/03
Posts: 7
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.

 
Profile Email
 Quote
emagin
 09/11/03 12:48PM  
++++-
Regular Poster

Status: offline


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!

 
Profile Email
 Quote
Dirk
 09/11/03 02:26PM  
AAAAA
Admin

Status: offline


Registered: 01/12/02
Posts: 13027
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

 
Profile Email Website
 Quote
jt
 09/11/03 04:53PM  
+----
Newbie

Status: offline


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.

 
Profile Email
 Quote
Content generated in: 0.64 seconds
New Topic Post Reply

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