Logician
02-15-2002, 10:00 PM
Hey there,
I have a "graduation year" and an extra "birthyear" (admin view only) user profile fields in my board, so I wrote this hack to make sure members are entering valid and acceptable numeric data for these fields. ;)
This hack will require your members to enter a numeric data (numbers) for a user profile field. If the user did not enter a number or if the number is not between the limits you set, he will get an error message and should go back and enter a valid number.
INSTALLATION
1- Login to your CP and create a new template named:
"error_numericfieldonly"
In your template specify your error message. eg:
-- cut --
You should enter number between X and B for the field A. Please go back and correct it.
-- cut --
2- In "User Profiles", create your profile field (should be a "required" field). After you create it, click "Modify User Profile Field". Find your field in the list, left mouse click on "EDIT" link and choose "Open in New Window". In the new window check your browser's address bar: at the end you'll see smt. like that "profilefieldid=5". This is your field's ID. Note that number.
3- Edit "register.php" and "member.php". Find this:
// ENTER ANY CUSTOM FIELD VALIDATION HERE!
//Make sure user didn't try to bypass the maxchars for the fields
Right after that ADD:
// Logician Numeric Required User Profile Hack
// REMEMBER to substitute correct number in $fieldX below!
$log_field=(float) $fieldX;
// Line below will round decimal numbers. If you let your users enter decimals, simply put // at the beginning of the line below
$log_field=round($log_field);
// Substitute 1920 and 1990 with your min.-max. limits.
if ($log_field < 1920 OR $log_field >1990 )
{eval("standarderror(\"".gettemplate("error_numericfieldonly")."\");"); exit;}
// REMEMBER to substitute correct number in $fieldX below!
$fieldX=(string) $log_field;
// Logician Numeric Required User Profile Hack
That's it.. Upload your files to your server. From now on, when a user registers or edits his profile, your board will check if he entered a valid numeric value for the field you set and will not let him register/change his profile unless he enters a valid number for this field. This restriction does not apply to you if you use Admin CP to change user fields. ;) Remember to recheck/edit field ID, if you add/remove/modify user profile fields in your CP.
Enjoy! \\=^))
Logician
I have a "graduation year" and an extra "birthyear" (admin view only) user profile fields in my board, so I wrote this hack to make sure members are entering valid and acceptable numeric data for these fields. ;)
This hack will require your members to enter a numeric data (numbers) for a user profile field. If the user did not enter a number or if the number is not between the limits you set, he will get an error message and should go back and enter a valid number.
INSTALLATION
1- Login to your CP and create a new template named:
"error_numericfieldonly"
In your template specify your error message. eg:
-- cut --
You should enter number between X and B for the field A. Please go back and correct it.
-- cut --
2- In "User Profiles", create your profile field (should be a "required" field). After you create it, click "Modify User Profile Field". Find your field in the list, left mouse click on "EDIT" link and choose "Open in New Window". In the new window check your browser's address bar: at the end you'll see smt. like that "profilefieldid=5". This is your field's ID. Note that number.
3- Edit "register.php" and "member.php". Find this:
// ENTER ANY CUSTOM FIELD VALIDATION HERE!
//Make sure user didn't try to bypass the maxchars for the fields
Right after that ADD:
// Logician Numeric Required User Profile Hack
// REMEMBER to substitute correct number in $fieldX below!
$log_field=(float) $fieldX;
// Line below will round decimal numbers. If you let your users enter decimals, simply put // at the beginning of the line below
$log_field=round($log_field);
// Substitute 1920 and 1990 with your min.-max. limits.
if ($log_field < 1920 OR $log_field >1990 )
{eval("standarderror(\"".gettemplate("error_numericfieldonly")."\");"); exit;}
// REMEMBER to substitute correct number in $fieldX below!
$fieldX=(string) $log_field;
// Logician Numeric Required User Profile Hack
That's it.. Upload your files to your server. From now on, when a user registers or edits his profile, your board will check if he entered a valid numeric value for the field you set and will not let him register/change his profile unless he enters a valid number for this field. This restriction does not apply to you if you use Admin CP to change user fields. ;) Remember to recheck/edit field ID, if you add/remove/modify user profile fields in your CP.
Enjoy! \\=^))
Logician