Log in

View Full Version : Save old emails?


Boofo
09-14-2005, 04:50 AM
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

if ($this->existing['usergroupid'] != 3 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:
$this->userfield["fieldxx"] = $this->fetch_field('email'); To:
$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


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


to


$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):


$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?

if (strpos($this->fetch_field('field6'), $this->fetch_field('email') !== false)
if ($this->existing['usergroupid'] != 3 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:

if ($this->existing['usergroupid'] != 3 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

if ($this->existing['usergroupid'] != 3 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'));
}