PDA

View Full Version : Set 'Receive Admin Emails' according to content of a customfield


criscokid
07-10-2005, 05:23 PM
I have a custom user field that is a text field - in this case the content is either Yes or No. Using a mySQL command I'd like to set 'Receive Admin Emails' to 'yes' if the value of a custom field contains the text 'Yes'.

Does anyone have any suggestions on what command I should use?

sabret00the
07-13-2005, 04:12 PM
run it via a cron that will check what is says and then set it in the user table.

i.e.

$rawdata = $DB_site->query("
SELECT userid, fieldX
FROM usertextfield
WHERE LIKE '" . strtolower('%yes%') . "'
");

while ($users_to_change = $DB_site->fetch_array($rawdata))
{
$useridstochange .= " $users_to_change[userid]";
}

$newuserid = trim($useridstochange);
$DB_site->query("
UPDATE users
SET receiveadminemails = 1 ## or whatever the value is ##
WHERE userid IN($newuserid)
");


something a little like that :)