vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Force Profile Update Hack (https://vborg.vbsupport.ru/showthread.php?t=40594)

roxics 07-02-2002 10:00 PM

Force Profile Update Hack
 
This hack was made by gforce2001 on request by myself here:
https://vborg.vbsupport.ru/showthrea...threadid=40584
He deserves a big thank you for it :) It is being release with his permission.

What does this hack do?

Here?s a Scenario:
You have a board with 1000 members. You decide you want to add a new required field to your members profiles. Well everyone who registers after you add the new required field will be required to fill it in to complete registration (makes perfect sense :) ). But your 1000 existing members can skate by without updating and continue to go about posting and such.

This hack forces your existing members to update the new fields you?ve added to the profiles. You can set it so that once members log in and try to view the board, reply to a post, post new topics, search forums, and so on, they will instead get a message that tells them they need to first update the new fields in their profile before they can go any further.

Why use this hack?
Even if you tell your members to go and update the new profile fields they won?t always do it. But if they are forced to do it before they can post or view the board then they will do it.

What am I using it for?
I have 300 existing members and I now want all my members to be searchable by their location and key interests. But my members need to have this information in their profiles before anyone can get any results. So I'm forcing them to put this new information in. Doesn't sound nice but it's needed to make the system work. This hack gives me the power to force members to update that profile before they can do anything they want to do on the board.

What can you restrict?
ForumDisplay, Calendar, Newreply, Newthread, Poll, etc.

Warning: Do not use this hack on usercp.php. Your members need access to edit their profiles.

Step by Step;

Step 1. Open up the file you want to restrict (i.e. newreply.php)

Step 2. Find:
PHP Code:

require('./global.php'); 

Under it put:
PHP Code:

 // +++++++ Start Erroring Missing User Profile Fields [ Start ] +++++++ 
function chkprofilefields($userid$n) {
  global 
$DB_site;
  
  
$fieldnumber="field$n";
  
$getu=$DB_site->query_first("SELECT $fieldnumber FROM userfield WHERE userid='$userid'");
  
$field=$getu[$fieldnumber];
    if(empty(
$field)) {
      eval(
"standarderror(\"".gettemplate("error_emptyrequiredfields")."\");");
      exit;
    }
}
// +++++++ Start Erroring Missing User Profile Fields [ End ] +++++++ 

Step 3. Log into your Admin CP and go to "User Profile Fields > Modify".
Hover your mouse over the edit link of the forum you want to make your exisiting members require to fill out. Note the last number in the url ( the profilefieldid= number). Write it down.

Step 4. Replace the ## in the code below with the number you just wrote down.
PHP Code:

chkprofilefields($bbuserinfo[userid],##); 

Now put that last code right under the larger code given above. Note: If there is more then one profile field you now require then add another line of that last code underneath the previous.
Example;
PHP Code:

chkprofilefields($bbuserinfo[userid],7);
chkprofilefields($bbuserinfo[userid],13);
chkprofilefields($bbuserinfo[userid],15); 

Repeat this process for whatever files you want to suspend from your users until they fill in the new profile fields (i.e. forumdisplay.php, newthread.php, calendar.php)

Step 5. Create a new template called: error_emptyrequiredfields

Place the folowing message in it (or whatever message you would like):

Quote:

Before you can go any further you need to update all profile fields that are now required on the forum. You can view your UserCP>Edit Profile and update it there. Thanks in advance!
Step 6. Smile :) That's it!

Smoothie 07-03-2002 07:50 AM

Quote:

Now put that last code right under the larger code given above.
Under:
PHP Code:

// +++++++ Start Erroring Missing User Profile Fields [ End ] +++++++ 

Yes?

Smoothie 07-03-2002 07:51 AM

How many queries does this add?

roxics 07-03-2002 07:53 AM

Yes you are correct.

Number of queries I don't know.

Admin 07-03-2002 07:59 AM

You don't need any queries, roxics. You can use this instead:
PHP Code:

function chkprofilefields($userid$fieldnumber) {
    global 
$DB_site$bbuserinfo;
  
    if (
$bbuserinfo['userid'] == $userid) {
        
$field $bbuserinfo['field'.$fieldnumber];
    } else {
        
$userinfo getuserinfo($userid);
        
$field $userinfo['field'.$fieldnumber];
    }

    if (empty(
$field)) {
        eval(
'standarderror("'.gettemplate('error_emptyrequiredfields').'");');
    }


This will only generate a query if it's used not on the browsing user.

roxics 07-03-2002 08:07 AM

Excellent!

bandersen 07-03-2002 03:17 PM

I have installed this on newreply and newthread, and it's working like a charm. Thank you.

g-force2k2 07-03-2002 04:08 PM

Quote:

Originally posted by FireFly
PHP Code:

function chkprofilefields($userid$fieldnumber) {
    global 
$DB_site$bbuserinfo;
  
    if (
$bbuserinfo['userid'] == $userid) {
        
$field $bbuserinfo['field'.$fieldnumber];
    } else {
        
$userinfo getuserinfo($userid);
        
$field $userinfo['field'.$fieldnumber];
    }

    if (empty(
$field)) {
        eval(
'standarderror("'.gettemplate('error_emptyrequiredfields').'");');
    }


This will only generate a query if it's used not on the browsing user.

thanks FireFly... seriously its good to learn somethign new :D I will have to remember this for further refrences ;) because it doesn't run queries and that is cool :D but just a question... doesn't the getuserinfo() function use a query or no?

g-force2k2

Admin 07-03-2002 04:46 PM

getuserinfo() does, but we only call it if we need to.

g-force2k2 07-03-2002 04:48 PM

ah ic... thanks again for the explanation FireFly :D

g-force2k2


All times are GMT. The time now is 12:27 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01554 seconds
  • Memory Usage 1,765KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete