Hi... I've got my site up and running nicely... I do want to have the users that register to have their full name required upon doing so.
I went through the tutorial and when I finished my site gave me a blank screen. So, I turned the customization to false in config.php. The fields were there but didn't work properly. Like it said "you didn't type your email address twice when there is only 1 email address field. So I turned it back to the way it was for now.
Text Formatted Code
/* Creat 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;
}
// Delete any records from custom tables you may have used
function CUSTOM_userDelete($uid)
{
return true;
}
/* Called from users.php - when user is displaying a member profile.
* This function can now return any extra fields that need to be shown.
* Output is then replaced in {customfields} -- This variable needs to be added
* to your templates
* Template: path_layout/users/profile/profile.thtml
*/
function CUSTOM_userDisplay($uid)
{
global $_CONF, $_TABLES;
$var = "Value from custom table";
$retval .= '<tr>
<td align="right"><b>Custom Fields:</b></td>
<td>' . $var .'</td>
</tr>';
return $retval;
}
/* Function called when editing user profile. */
/* Called from usersettings.php - when user is eding their own profile */
/* and from admin/user.php when admin is editing a member profile */
/* This function can now return any extra fields that need to be shown for editing */
/* Output is then replaced in {customfields} -- This variable needs to be added to your templates */
/* User: path_layout/preferences/profile.thtml and Admin: path_layout/admin/user/edituser.thtml */
/* This example shows adding the Cookie Timeout setting and extra text field */
/* As noted: You need to add the {customfields} template variable. */
/* For the edituser.thtml - maybe it would be added about the {group_edit} variable. */
function CUSTOM_userEdit($uid)
{
global $_CONF, $_TABLES;
$var = "Value from custom table";
$cookietimeout = DB_getitem($_TABLES['users'], 'cookietimeout', $uid);
$selection = '<select name="cooktime">' . LB;
$selection .= COM_optionList ($_TABLES['cookiecodes'], 'cc_value,cc_descr', $cookietimeout, 0);
$selection .= '</select>';
$retval .= '<tr>
<td align="right">Remember user for:</td>
<td>' . $selection .'</td>
</tr>';
$retval .= '<tr>
<td align="right"><b>Custom Fields:</b></td>
<td><input type="text" name="custom1" size="50" value="' . $var .'"></td>
</tr>';
$retval .= '<tr><td colspan="2"><hr></td></tr>';
return $retval;
}
/* 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");
}
}
/**
* Main Form used for Custom membership when member is registering
*
* 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 = '<input type="submit" value="Register Now!">';
$message = "<blockquote style=\"padding-top:10px;\"><b>Please complete the application below. Once you have completed the application, click the Register Now! button and the application will be processed immediately.</b></blockquote>";
$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());
$user_templates->parse('output', 'memberdetail');
$retval .= $user_templates->finish($user_templates->get_var('output'));
return $retval;
}
Text Formatted Code
<?php
/* 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 $_TABLES;
$grad_year = COM_applyFilter($_POST['cust_gradyear'],true);
$fullname = COM_applyFilter($_POST['cust_fullname']);
// Ensure all data is prepared correctly before inserts, quotes may need to be escaped with addslashes()
DB_query("INSERT INTO {$_TABLES['localuserinfo']} (uid,grad_year) VALUES ('$uid', '$grad_year')");
DB_query("UPDATE {$_TABLES['users']} SET fullname = '$fullname' WHERE uid='$uid'");
return true;
}
// Delete user record from custom user info table
function custom_userdelete($uid) {
global $_TABLES;
DB_query("DELETE FROM {$_TABLES['localuserinfo']} WHERE uid='$uid'");
return true;
}
/* Called from users.php - when user is displaying a member profile */
/* This function will return any extra fields that need to be shown */
/* Output is then replaced in {customfields) -- This variable needs to be added to your templates */
/* Template: path_layout/users/profile/profile.thtml */
function custom_userdisplay($uid) {
global $_CONF,$_TABLES;
$grad_year = DB_getItem($_TABLES['localuserinfo'], "grad_year", "uid='$uid'");
$fullname = DB_getItem($_TABLES['users'], "fullname", "uid='$uid'");
$retval .= '<tr>
<td align="right"><b>Full Name:</b></td>
<td>' . $fullname .'</td>
</tr>';
$retval .= '<tr>
<td align="right"><b>Graduation Year:</b></td>
<td>' . $grad_year .'</td>
</tr>';
return $retval;
}
/* Function called when editing user profile. */
/* Called from usersettings.php - when user is eding their own profile */
/* and from admin/user.php when admin is editing a member profile */
/* This function will return any extra fields that need to be shown for editing */
/* Output is then replaced in {customfields} -- This variable needs to be added to your templates */
/* User: path_layout/preferences/profile.thtml and Admin: path_layout/admin/user/edituser.thtml */
function custom_useredit($uid) {
global $_TABLES,$_CONF;
$grad_year = DB_getItem($_TABLES['localuserinfo'], "grad_year", "uid='$uid'");
$fullname = DB_getItem($_TABLES['users'], "fullname", "uid='$uid'");
$retval .= '<tr>
<td align="right"><b>Full Name:</b></td>
<td><input type="text" name="cust_fullname" size="50" value="' . $fullname .'"></td>
</tr>';
$retval .= '<tr>
<td align="right"><b>Graduation Year:</b></td>
<td><input type="text" name="cust_gradyear" size="5" maxlength="4" value="' . $grad_year .'"></td>
</tr>';
$retval .= '<tr><td colspan="2"><hr></td></tr>';
return $retval;
}
/* Function called when saving the user profile. */
function custom_usersave($uid) {
global $_TABLES;
$grad_year = COM_applyFilter($_POST['cust_gradyear'],true);
$fullname = COM_applyFilter($_POST['fullname']);
DB_query("UPDATE {$_TABLES['users']} SET fullname='$fullname' WHERE uid='$uid'");
if ($grad_year > 0) {
DB_query("UPDATE {$_TABLES['localuserinfo']} SET grad_year='$grad_year' WHERE uid='$uid'");
}
}
/* Main Form used for Custom membership when member is registering */
function custom_userform($uid="",$msg="") {
global $_CONF,$_TABLES, $LANG04;
if (!empty($msg)) {
$retval .= COM_startBlock($LANG04[21]) . $msg . COM_endBlock();
}
$post_url = $_CONF['site_url']."/users.php";
$postmode = "create";
$submitbutton = '<input type="submit" value="Register Now!">';
$passwd_input = "";
$message = "<br><font color=black><b>Please complete the application below. Once you have completed the application, click the Submit button and the application will be processed immediately.</b></font>";
$A=array();
$user_templates = new Template ($_CONF['path_layout'] . 'custom');
$user_templates->set_file('memberdetail', 'memberdetail.thtml');
$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', "Username");
$user_templates->set_var('USERNAME_HELP', "Name to be used when accessing this site");
$user_templates->set_var('username', $A['username']);
$user_templates->set_var('passwd_input', $passwd_input);
$user_templates->set_var('EMAIL', "Email Address");
$user_templates->set_var('EMAIL_HELP', "Valid email address");
$user_templates->set_var('email', $A['email']);
$user_templates->set_var('FULLNAME', "Full Name");
$user_templates->set_var('FULLNAME_HELP', "First and Last Name");
$user_templates->set_var('fullname', $A['fullname']);
$user_templates->set_var('GRADYEAR', "Graduation Year");
$user_templates->set_var('GRADYEAR_HELP', "That big year!");
$user_templates->set_var('grad_year', "");
$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());
$user_templates->parse('output', 'memberdetail');
$retval .= $user_templates->finish($user_templates->get_var('output'));
return $retval;
}
?>
Is that wrong? Because in front page in split view it shows a bunch of stuff on the design area where as it did not have anything there prior to pasting that code?