/** * Main Form used for Custom membership when member is registering * * Modified to support the CAPTCHA Plugin - REQUIRES Geeklog v1.3.11sr2 or above * * Note: Requires a file custom/memberdetail.thtml in every theme that is * installed on the site! * * @param string $msg an error message to display or the word 'new' * @return string HTML for the registration form * */ function CUSTOM_userForm ($msg = '') { global $_CONF, $_TABLES, $LANG04; if (!empty ($msg) && ($msg != 'new')) { $retval .= COM_startBlock($LANG04[21]) . $msg . COM_endBlock(); } $post_url = $_CONF['site_url'] . '/users.php'; $postmode = 'create'; $submitbutton = ''; $message = "
Please complete the application below. Once you have completed the application, click the Register Now! button and the application will be processed immediately."; $user_templates = new Template ($_CONF['path_layout'] . 'custom'); $user_templates->set_file('memberdetail', 'memberdetail.thtml'); $user_templates->set_var('site_url', $_CONF['site_url']); $user_templates->set_var('layout_url', $_CONF['layout_url']); $user_templates->set_var('post_url', $post_url); $user_templates->set_var('startblock', COM_startBlock("Custom Registration Example")); $user_templates->set_var('message', $message); $user_templates->set_var('USERNAME', $LANG04[2]); $user_templates->set_var('USERNAME_HELP', "Name to be used when accessing this site"); $username = ''; if (isset ($_POST['username'])) { $username = COM_applyFilter ($_POST['username']); } $user_templates->set_var('username', $username); $user_templates->set_var('EMAIL', $LANG04[5]); $user_templates->set_var('EMAIL_HELP', $LANG04[33]); $email = ''; if (isset ($_POST['email'])) { $email = COM_applyFilter ($_POST['email']); } $user_templates->set_var('email', $email); $user_templates->set_var('EMAIL_CONF', $LANG04[124]); $user_templates->set_var('EMAIL_CONF_HELP', $LANG04[126]); $email_conf = ''; if (isset ($_POST['email_conf'])) { $email_conf = COM_applyFilter ($_POST['email_conf']); } $user_templates->set_var('email_conf', $email_conf); $user_templates->set_var('FULLNAME', $LANG04[3]); $user_templates->set_var('FULLNAME_HELP', $LANG04[34]); $fullname = ''; if (isset ($_POST['fullname'])) { $fullname = strip_tags ($_POST['fullname']); } $user_templates->set_var('fullname', $fullname); $user_templates->set_var('user_id', $user); $user_templates->set_var('postmode', $postmode); $user_templates->set_var('submitbutton', $submitbutton); $user_templates->set_var('endblock', COM_endBlock()); /* * Check to see if CAPTCHA plugin is installed and enabled * if yes, call the function to add the CAPTCHA image. */ if ( function_exists('plugin_templatesetvars_captcha') ) { plugin_templatesetvars_captcha('registration', $user_templates); } $user_templates->parse('output', 'memberdetail'); $retval .= $user_templates->finish($user_templates->get_var('output')); return $retval; } /** * 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 = ''; if ( function_exists('plugin_itemPreSave_captcha') ) { $msg = plugin_itemPreSave_captcha('registration',$username); if ( $msg != '' ) { return $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; } /* 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 $_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); } $homepage = ''; if (isset ($_POST['homepage'])) { $homepage = COM_applyFilter ($_POST['homepage']); $homepage = addslashes ($homepage); } $fullname = ''; if (isset ($_POST['fullname'])) { // COM_applyFilter would strip special characters, e.g. quotes, so // we only strip HTML $fullname = strip_tags ($_POST['fullname']); $fullname = addslashes ($fullname); } // Note: In this case, we can trust the $uid variable to contain the new // account's uid. DB_query("UPDATE {$_TABLES['users']} SET email = '$email', homepage = '$homepage', fullname = '$fullname' WHERE uid = $uid"); return true; } /* Function called when saving the user profile. */ /* This function can now update any extra fields */ function CUSTOM_userSave($uid) { global $_CONF, $_TABLES; $cooktime = 0; if (isset ($_POST['cooktime'])) { $cooktime = COM_applyFilter ($_POST['cooktime'], true); if ($cooktime < 0) { $cooktime = 0; } DB_query("UPDATE {$_TABLES['users']} SET cookietimeout = $cooktime WHERE uid = $uid"); } }