vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Force Current Members To Fill Out Required Profile Field (https://vborg.vbsupport.ru/showthread.php?t=69270)

integra99 09-11-2004 08:06 PM

First, open the STANDARD_ERROR template, and copy it to a new template named zzzz_emptyreqfields. Then replace $errormessage with
Code:

There are new required profile field(s) since your last visit: click <a href="profile.php?$session[sessionurl]do=editprofile">$vbphrase[edit_profile]</a> to update.
Then edit global.php and add the following code right before the end of the file, i.e., right before the last ?>
Code:

if ($bbuserinfo['userid'] AND $bbuserinfo['userid'] > 1) {
        if (!empty($_SERVER["REQUEST_URI"])) {                  ///// check your phpinfo
                $zzzz_noise = $_SERVER["REQUEST_URI"];            ///// check your phpinfo
        }
        else { $zzzz_noise = "zzzz"; }
        $zzzz_regex = "(profile\.php|usercp\.php)";
        if (!eregi($zzzz_regex,$zzzz_noise)) {
                $zzzz_reqfields = $DB_site->query("SELECT * FROM ".TABLE_PREFIX."profilefield WHERE required=1");
                if ($DB_site->num_rows($zzzz_reqfields)) {
                        while ($zzzz_reqfield = $DB_site->fetch_array($zzzz_reqfields)) {
                                $zzzz_ufields = $DB_site->query_first("SELECT * FROM ".TABLE_PREFIX."userfield WHERE userid='$bbuserinfo[userid]'");
                                $zzzz_fieldname = "field$zzzz_reqfield[profilefieldid]";
                                $zzzz_field = $zzzz_ufields[$zzzz_fieldname];
                                if (empty($zzzz_field)) {
                                        $zzzz_templatename = "zzzz_emptyreqfields";
                                        eval('print_output("' . fetch_template($zzzz_templatename) . '");');
                                        exit;
                                }
                        }
                }
        }
}

Note: you may not have $_SERVER["REQUEST_URI"] on your machine so check phpinfo and use an applicable $_SERVER element.

calorie 09-11-2004 08:59 PM

Thanks integra99! Hopefully the required steps are now more clear for others. BTW, here is a mini script to check for other applicable $_SERVER elements.
PHP Code:

<?php

if (isset($_SERVER['REQUEST_URI'])) {
  echo 
"\$_SERVER['REQUEST_URI'] = ".$_SERVER['REQUEST_URI']."<br><br>";
}
if (isset(
$_SERVER['SCRIPT_FILENAME'])) {
  echo 
"\$_SERVER['SCRIPT_FILENAME'] = ".$_SERVER['SCRIPT_FILENAME']."<br><br>";
}
if (isset(
$_SERVER['SCRIPT_URI'])) {
  echo 
"\$_SERVER['SCRIPT_URI'] = ".$_SERVER['SCRIPT_URI']."<br><br>";
}
if (isset(
$_SERVER['SCRIPT_URL'])) {
  echo 
"\$_SERVER['SCRIPT_URL'] = ".$_SERVER['SCRIPT_URL']."<br><br>";
}
if (isset(
$_SERVER['SCRIPT_NAME'])) {
  echo 
"\$_SERVER['SCRIPT_NAME'] = ".$_SERVER['SCRIPT_NAME']."<br><br>";
}
if (isset(
$_SERVER['PATH_TRANSLATED'])) {
  echo 
"\$_SERVER['PATH_TRANSLATED'] = ".$_SERVER['PATH_TRANSLATED']."<br><br>";
}
if (isset(
$_SERVER['PHP_SELF'])) {
  echo 
"\$_SERVER['PHP_SELF'] = ".$_SERVER['PHP_SELF']."<br><br>";
}

?>


Lionel 10-11-2004 04:57 AM

Very useful. Is there a way to tell it to look only for some required field? I want birthdays, gender and country only. Unfortunately the weather hack has a required field (required when you select the weather) and that force people to choose it too. Perhaps a conditionals if condition required and different than weather field?

calorie 10-28-2004 03:21 AM

Try changing...
PHP Code:

$zzzz_reqfields $DB_site->query("SELECT * FROM ".TABLE_PREFIX."profilefield WHERE required=1"); 

To the following...
PHP Code:

$zzzz_reqfields $DB_site->query("SELECT * FROM ".TABLE_PREFIX."profilefield WHERE required=1 AND profilefieldid NOT IN(1,2,3)");

// where 1,2,3 are from the fieldX names and X is a number (see the vB User Profile Field Manager for fieldX names) 


xg3 10-30-2004 03:14 AM

Calorie, your suggestion didn't work...it keeps sending me to the error page even after I have filled in the require field. Can you find another solution?

theArchitect 11-10-2004 10:44 AM

*theArchitect clicks install*.

Nice hack, and very useful.

Only one problem. When I add the necessary code to the global.php file I can't update anything. I first get sent to a page saying that there are new profile fields that I need to fill out and when I click on the link I get told that I need to fill out new profile fields before i can browse the forum. So I end up in a new profile field loop.

I decided to add the code to the index.php page instead and this works fine. Though people can still use the rest of the forum if they choose to ignore the prompt. Do you know what I did wrong?

CuriousGeorge 12-01-2004 11:32 PM

I am planning on implementing this hack into my boards. Yet, I am wondering if its possible to add onto it slightly.

I want a profile field such as "I Agree to post by the rules" that everyone has to fill out. However, if a user choses 'no' I want their account to be placed ina usergroup that will not let them post until they choose 'yes' in their profile field.

Any guidance on how I can go about accomplishing this? Thanks.

Bison 12-11-2004 01:51 PM

Quote:

Originally Posted by CuriousGeorge
I am planning on implementing this hack into my boards. Yet, I am wondering if its possible to add onto it slightly.

I want a profile field such as "I Agree to post by the rules" that everyone has to fill out. However, if a user choses 'no' I want their account to be placed ina usergroup that will not let them post until they choose 'yes' in their profile field.

Any guidance on how I can go about accomplishing this? Thanks.

I might suggest this:

add a condition that checks the value from that field after submission, if the value is "NO" ... then change that users groupid to the groupid you want.

if zzz_customfield = 'NO'{ bbusergroupid = 10};

T3MEDIA 12-15-2004 12:19 PM

Quote:

Originally Posted by integra99
Note: you may not have $_SERVER["REQUEST_URI"] on your machine so check phpinfo and use an applicable $_SERVER element.

how do you know what element to use???

T3MEDIA 12-15-2004 12:34 PM

I get a heavy loop. Dont know what is up. Wish I could use this baby.


All times are GMT. The time now is 01:12 AM.

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.01005 seconds
  • Memory Usage 1,759KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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