Welcome to Geeklog, Anonymous Tuesday, April 23 2024 @ 10:48 pm EDT

Geeklog Forums

Custom registration Question


Theophile

Anonymous
I plan to adapt the info from the "Custom registration example" thread to add "Full Name" to the required fields, but I have another more advanced question.

I want to make it so that if users register with an email address from a certain domain, they are automatically added to a given group. I know this is beyond my technical abilities but I am hoping someone else might be able to knock it out for me.

Any suggestions appreciated! Thanks!
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
I'm no expert on the custom registration code (it is confusing) but it seems like you would modify CUSTOM_userCreate with the following call:
Text Formatted Code
if (strstr($email,'domain.com')) {
    include_once $_CONF['path_system'].'lib-user.php';
    USER_addGroup('name of group', $uid);
}

I'm not sure the include_once is needed. But it shouldn't hurt.
 Quote

Theophile

Anonymous
Thanks for the suggestion.

I gave it a try, but it didn't work. Cry

Upon further investigation, it looks like Geeklog doesn't recognize the USER_addGroup function (I couldn't find it anywhere in the distribution). I went poking around trying to find code in the distro that adds a user to a g roup and the closest thing I could find is in the public_html/admin/groups.php file. Buried in there is this:

Text Formatted Code
if (!empty ($groups)) {
            for ($i = 1; $i <= sizeof ($groups); $i++) {
                if (in_array ($grp_id, $GroupAdminGroups)) {
                    if ($VERBOSE) COM_errorLog("adding group_assignment " . current($groups) . " for $grp_name",1);
                    $sql = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_grp_id) VALUES (" . current($groups) . ",$grp_id)";
                    DB_query($sql);
                }
                next($groups);
            }
        }


Looks like whenever you add a user to a group, you have to directly modify the SQL tables. Am I going in the right direction here? I'm really bad at this.

Thanks in advance!!!!
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
It may be a Geeklog 1.4.1 only function. It is definitely there.
 Quote

Theophile

Anonymous
I am running 1.4.1

Do I have it in the right place?

Text Formatted Code
function CUSTOM_userCreate ($uid)
{
    global $_CONF, $_TABLES;

    // Ensure all data is prepared correctly before inserts, quotes may need to
    // be escaped with addslashes()
    $email = '';
    if (isset ($_POST['email'])) {
        $email = COM_applyFilter ($_POST['email']);
        $email = addslashes ($email);
    }

if (strstr($email,'mc.edu')) {
    include_once $_CONF['path_system'].'lib-user.php';
    USER_addGroup('students', $uid);
}

    $homepage = '';
    if (isset ($_POST['homepage'])) {
        $homepage = COM_applyFilter ($_POST['homepage']);
        $homepage = addslashes ($homepage);
    }


etc...

Thanks
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
For some odd reason, it doesn't lookup group names for you.
Text Formatted Code
if (strstr($email,'mc.edu')) {
    include_once $_CONF['path_system'].'lib-user.php';
    $grp_id = DB_getItem($_TABLES['groups']), 'grp_id', "grp_name = 'students'");
    USER_addGroup($grp_id, $uid);
}
 Quote

Theophile

Anonymous
Again, thank you so much for your help.

The above code gives this error:
Text Formatted Code
Parse error: syntax error, unexpected ',' in /home/.tamara/theophile/notsodirtydozen.com/geeklog-1.4.1/system/lib-custom.php on line 164


In context, line 164 is this line:
Text Formatted Code
$grp_id = DB_getItem($_TABLES['groups']), 'grp_id', "grp_name = 'students'");


Any idea what the culprit may be?

THankS!!
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Extra parenthesis after $_TABLES['groups']:
In context, line 164 is this line:
Text Formatted Code
$grp_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'students'");

 Quote

Theophile

Anonymous
Sir, you are a scholar and a gentleman.

Thank you.

Big Grin
 Quote

Status: offline

Chaos Creator

Forum User
Junior
Registered: 02/10/08
Posts: 24
Location:Asheville, NC
I would like to incorporate the custom registration into my site, but I'd like the user to be able to choose their own password, and also I'd like to have fields for birthdates and a referrer field that will be able to add a 'number of referrals' field to the referring user's profile.

I've tried a few things, but either I'm not putting the code in the correct place, or my code is just completely bunk.

Any ideas?
 Quote

All times are EDT. The time is now 10:48 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