Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: 1.00, by Logician Logician is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 02-15-2002 Last Update: Never Installs: 9
 
No support by the author.

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:
PHP Code:
    // ENTER ANY CUSTOM FIELD VALIDATION HERE!
    //Make sure user didn't try to bypass the maxchars for the fields 
Right after that ADD:

PHP Code:
// 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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 02-16-2002, 06:58 PM
TheComputerGuy's Avatar
TheComputerGuy TheComputerGuy is offline
 
Join Date: Oct 2001
Location: TX
Posts: 580
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sweet great hack, I like it
Reply With Quote
  #3  
Old 02-18-2002, 08:56 PM
Ruth Ruth is offline
 
Join Date: Oct 2001
Posts: 171
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

great hack, i requested such hack long time ago specifically for a graduation year, plus it would be nice to have a count down for each member to the graduation year
Reply With Quote
  #4  
Old 05-14-2002, 01:14 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excuse me.
Great idea and nice small hack.

Actually, with che code you suggested, such a check for one field would be performed each custom field for the same X number (it's within the while clause).
I think should be better to replace the above code with something like :
PHP Code:
    //HACK: Numeric Required Field in User Profile
    
if ($profilefield[profilefieldid]==X) {   // number of field you're checking
      
if (is_numeric($$varname)) {
        
$log_field=round((float)$$varname);
      } else {
        
$log_field=0;
      }
      if (
$log_field 1920 OR $log_field 1990 ) {
        eval(
"standarderror(\"".gettemplate("error_numericfieldonly")."\");");
        exit;
      }
      $
$varname=(string)$log_field;
    }
    
//HACK: Numeric Required Field in User Profile 
The problem rises mostly when you have required fields. If the above field it isn't numeric, the above exception comes before the required field one. This way I realized such a mis-function....

Thanks again and sorry the intrusion.
But I did this way and would share such a small work-around.
Bye
Reply With Quote
  #5  
Old 05-14-2002, 02:35 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@javelin: Honestly it's not a big deal for me which error user gets first : required field error or numeric entry error. But your code is a good enhancement for Admins who care, so thanks for sharing..

Regards,
Logician \\=^))
Reply With Quote
  #6  
Old 05-14-2002, 02:52 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of course. Nothing to say: your hack works and it's a nice idea (this reason I installed it too) ....
And when installed I found such a small problem; tried to fix it and though someone else could have the same...

Thanks again.
Bye
Reply With Quote
  #7  
Old 12-01-2002, 10:39 PM
KingsGambit KingsGambit is offline
 
Join Date: Oct 2002
Location: London, England
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great idea for a great hack. Our of curiosity, would it be possible to modify this to work for a *post* field. eg. Have an extra field in the newthread and newreply that requires numeric entry for the post to be accepted?
Reply With Quote
  #8  
Old 12-01-2002, 10:58 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by KingsGambit
Great idea for a great hack. Our of curiosity, would it be possible to modify this to work for a *post* field. eg. Have an extra field in the newthread and newreply that requires numeric entry for the post to be accepted?
clarify please.. Also posting your recent code that requires the hack will help..
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05179 seconds
  • Memory Usage 2,282KB
  • Queries Executed 21 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete