vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Save old emails? (https://vborg.vbsupport.ru/showthread.php?t=96231)

Boofo 09-14-2005 04:50 AM

Save old emails?
 
I want to update a hack that I used on vb3.0 that would save the old email address if a user other than usergroup 3 (awaiting email confirmation) changed it. The old hck used 2 queries in the profile, 1 to pull the email and one to update he profile field. I used a profile field to show the old emails but to admins only in the profile.

I'm not sure where to add it (the hook location) now and can I do it without 2 queries?

Andreas 09-14-2005 05:03 AM

I think you can do it without any Query (untested)

userdata_presave
PHP Code:

if ($this->existing['usergroupid'] != AND $this->existing['email] != $this->fetch_field('email'))
{
    $this->setfields["fieldxx"] = true;
    $this->userfield["fieldxx"] = $this->fetch_field('
email'); 



Boofo 09-14-2005 06:03 AM

Ok, I'll test this and get back to you. Thank you, sir. ;)

How would I go about adding a comma and a space between each email like the currently active users does?

Marco van Herwaarden 09-14-2005 09:13 AM

Change:
PHP Code:

$this->userfield["fieldxx"] = $this->fetch_field('email'); 

To:
PHP Code:

$this->userfield["fieldxx"] = ($this->userfield["fieldxx"]  ? $this->userfield["fieldxx"] . ", " $this->fetch_field('email') : $this->userfield["fieldxx"]); 


Andreas 09-14-2005 09:16 AM

And then change

PHP Code:

$this->userfield["fieldxx"] = ($this->userfield["fieldxx"]  ? $this->userfield["fieldxx"] . ", " $this->fetch_field('email') : $this->userfield["fieldxx"]); 

to

PHP Code:

$this->userfield["fieldxx"] = ($this->userfield["fieldxx"]  ? $this->userfield["fieldxx"] . ", " $this->fetch_field('email') : $this->fetch_field('email')); 

to make it work correctly ;)

Marco van Herwaarden 09-14-2005 09:23 AM

Lol, correct. :D

Boofo 09-14-2005 09:32 AM

LMAO @ Kirby. You guys kill me! LOL

Thank you both, sirs. ;)

Andreas 09-14-2005 11:07 AM

4th Revision of 1 Code line (LOL):

PHP Code:

$this->userfield['fieldxx'] = ($this->fetch_field('fieldxx'))  ? $this->fetch_field('fieldxx') . ', ' $this->fetch_field('email') : $this->fetch_field('email')); 


Boofo 09-14-2005 11:49 AM

Ok, that works now (after taking out one of these right parenthesis: ('fieldxx'))from the secoind variable) LOL

It is listing the emails like it should. But if you change the email back to what it once was, it relists that email again. Is that the way it should work?

Andreas 09-14-2005 11:58 AM

Yes. If you want to avoid that, wrap it in if (strpos($this->fetch_field('fieldxx'), $this->fetch_field('email')) === false)

Boofo 09-14-2005 12:05 PM

Like this?

PHP Code:

 if (strpos($this->fetch_field('field6'), $this->fetch_field('email') !== false)
 if (
$this->existing['usergroupid'] != AND $this->existing['email'] != $this->fetch_field('email')) 
 { 
     
$this->setfields['field6'] = true
     
$this->userfield['field6'] = ($this->fetch_field('field6')  ? $this->fetch_field('field6') . ', ' $this->fetch_field('email') : $this->fetch_field('email'));
 }



Andreas 09-14-2005 12:07 PM

Then you it would only execute if the email is already in the list.
Any there is a ) and a { missing.

Edited my previous Post.

Boofo 09-14-2005 12:18 PM

Ahhh, ok, I see what I need to do now.

Like this:

PHP Code:

 if ($this->existing['usergroupid'] != AND $this->existing['email'] != $this->fetch_field('email'))
{
if (
strpos($this->fetch_field('field6'), $this->fetch_field('email')) === false)
{
     
$this->setfields['field6'] = true;
     
$this->userfield['field6'] = ($this->fetch_field('field6') ? $this->fetch_field('field6') . ', ' $this->fetch_field('email') : $this->fetch_field('email'));
}



Andreas 09-14-2005 12:24 PM

The edited Version looks correct (if there are no missing brackets or whatever)

But you can shorten it
PHP Code:

if ($this->existing['usergroupid'] != AND $this->existing['email'] != $this->fetch_field('email') AND strpos($this->fetch_field('field6'), $this->fetch_field('email')) === false))
{
    
$this->setfields['field6'] = true;
    
$this->userfield['field6'] = (($this->fetch_field('field6'))  ? $this->fetch_field('field6') . ', ' $this->fetch_field('email') : $this->fetch_field('email'));




All times are GMT. The time now is 09:10 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.01236 seconds
  • Memory Usage 1,777KB
  • 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
  • (9)bbcode_php_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