vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Age in profile (https://vborg.vbsupport.ru/showthread.php?t=95470)

Boofo 09-01-2005 11:24 PM

Age in profile
 
Is there a way to take the age from the postbit and have it show up in a member's profile?

Andreas 09-01-2005 11:46 PM

Mainly just a Copy&Paste Job :)

Hook: member_complete
PHP Code:

$curyear vbdate('Y'TIMENOWfalsefalse);
$curmonth vbdate('n'TIMENOWfalsefalse);
$curday vbdate('j'TIMENOWfalsefalse);

$date explode('-'$userinfo['birthday']);
if (
$curyear $date[2] AND $date[2] != '0000')
{
    
$userinfo['age'] = $curyear $date[2];
    if (
$curmonth $date[0] OR ($curmonth == $date[0] AND $curday $date[1]))
    {
        
$userinfo['age']--;
    }
    
    if (
$userinfo['age'] >= 101)
    {
        unset(
$userinfo['age']);
    }



Boofo 09-01-2005 11:59 PM

I tried do it this way but couldn't get it to show up. I was using the wrong variables in my code. ;)

How do I get it to only show if you have it turned on for the postbit?

Andreas 09-02-2005 12:04 AM

Wrap it in
PHP Code:

if ($vbulletin->options['postelements'] & 1)
{


Btw.: Above Code is untested, but should work.

Boofo 09-02-2005 12:09 AM

I just tried the member_complete code you posted and it doesn't show up in the profile either. :(

What has replaced this in 3.5?

Quote:

$gotage

Andreas 09-02-2005 12:25 AM

Quote:

I just tried the member_complete code you posted and it doesn't show up in the profile either.
You did place $userinfo[age] in Template MEMBERINFO, right?

$gotage doesn't appear in any vBulletin 3.0 Files?

Boofo 09-02-2005 01:28 AM

Yessir, I did. ;)

Here's the code from the class_postbit.php that I converted earlier (to what you almost have in youe code) and it didn't work either. :(

It looks like they are using $this->cache['age'] in place of $gotage now.

PHP Code:

   // Generate Age
  
if ($this->registry->options['postelements'] & POST_SHOW_AGE)
  {
   if (!
$this->cache['year'])
   {
    
$this->cache['year'] = vbdate('Y'TIMENOWfalsefalse);
    
$this->cache['month'] = vbdate('n'TIMENOWfalsefalse);
    
$this->cache['day'] = vbdate('j'TIMENOWfalsefalse);
   }
   if (empty(
$this->cache['age'][$this->post['userid']]))
   {
    
$date explode('-'$this->post['birthday']);
    if (
$this->cache['year'] > $date[2] AND $date[2] != '0000')
    {
     
$this->post['age'] = $this->cache['year'] - $date[2];
     if (
$this->cache['month'] < $date[0] OR ($this->cache['month'] == $date[0] AND $this->cache['day'] < $date[1]))
     {
      
$this->post['age']--;
     }
     if (
$this->post['age'] < 101)
     {
      
$this->cache['age'][$this->post['userid']] = $this->post['age'];
     }
     else
     {
      unset(
$this->post['age']);
     }
    }
   }
   else
   {
    
$this->post['age'] = $this->cache['age'][$this->post['userid']];
   }
  } 


Andreas 09-02-2005 01:42 AM

OK ... time to check the Code (although I don't see why it should not work).

Boofo 09-02-2005 01:44 AM

You got me on this one, Kirby. I have been trying to get it to show in the profile for 2 days now. ;)

Andreas 09-02-2005 01:52 AM

Naargh. Well, the Code is correct - but the Data it relies on isn't ;)

$userinfo['birthday'] is already formatted at this point. But in member_start it isn't yet defined ...

So:

Hook: fetch_userinfo
PHP Code:

if (THIS_SCRIPT == 'member')
{
    
$user['realbirthday'] = $user['birthday'];


Hook: member_complete
PHP Code:

$curyear vbdate('Y'TIMENOWfalsefalse);
$curmonth vbdate('n'TIMENOWfalsefalse);
$curday vbdate('j'TIMENOWfalsefalse);

$date explode('-'$userinfo['realbirthday']);
if (
$curyear $date[2] AND $date[2] != '0000')
{
    
$userinfo['age'] = $curyear $date[2];
    if (
$curmonth $date[0] OR ($curmonth == $date[0] AND $curday $date[1]))
    {
        
$userinfo['age']--;
    }
    
    if (
$userinfo['age'] >= 101)
    {
        unset(
$userinfo['age']);
    }


10 minutes ... hmm. Too long :(
I am getting old - or tired.

Boofo 09-02-2005 02:50 AM

Thank you, sir, that worked. ;)

Just curious, but how did you figure out that the birthday variable wasn't defined in member_start?

Andreas 09-02-2005 10:05 AM

1st Step: DEVDEBUG($userinfo[age]), did show nothing
2nd Step: DEVDEBUG($userinfo[birthday])
=> Aaargh, it's formatted
3rd Step: Ok, lets check if there are Hooks in member.php executed earlier.
Bad, there are none
4th Step: OK, so lets use fetch_userinfo which must be called to get the User Info
=> Working

Boofo 09-02-2005 04:27 PM

Thank you, sir. Maybe next time I can try this approach BEFORE I start beating my head against the keyboard. ;)

Oblivion Knight 09-02-2005 04:53 PM

When I grow up, I want to be like Kirby.. ;)


All times are GMT. The time now is 11:39 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.01123 seconds
  • Memory Usage 1,784KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete