MyBB Community Forums

Full Version: Mail message on user activation by admin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Dear all,

I found a (old) plugin of Schnibble and want to modify that for ver 1.4.
But one way or the other I don't get it to work,

The hook that I am using is....
$plugins->add_hook("member_activate_accountactivated", "mailoa_start");

function mailoa_start() {
global $db, $mybb, $settings, $cache;

$query = $db->query("SELECT username, email FROM ".TABLE_PREFIX."users WHERE uid='".intval($mybb->input['uid'])."'");
$user = $db->fetch_array($query);

if ($user['email'] != '') {
$search = array('{user}','{site}','{url}');
$replace = array($user['username'], $settings['bbname'], $settings['bburl']);
$subject = str_replace($search, $replace, $settings['mailoa_subject']);
$message = str_replace($search, $replace, $settings['mailoa_body']);

my_mail($user['email'], $subject, $message);
}
}


But since the mail never arrives I think the mailoa_start funcyion is never fired.

I have checked and I can receiv mail via MyBB (tested with Mass mail feature) And the user has an email address.

Thanks for the support.
i think this goes in the plugin modifaction section
$query = $db->query("SELECT username, email FROM ".TABLE_PREFIX."users WHERE uid='".intval($mybb->input['uid'])."'");

Instead of $mybb->input['uid'] use $user['uid'], because the uid isn't always specified in the request (could be a username).

Also check the Mail Logs in the ACP Tools section to see if the mail is being sent.
Thanks for the reply.

But the reason I posted this message because it looks like the hook does not work since I do not get any mail when I activate the user as admin.

I have tried to put is some debug info with the echo command to see if the function mailoa_start is executed but I do not see any echo's or other screen blips.
The plugin hook you're using only covers the front-end activation (member activates self).

For admin activation, you need to use this plugin hook:

$plugins->run_hooks("admin_user_users_coppa_activate_commit");

You can find it in admin/modules/users/users.php
I really thought this was the solution but I still cannot get it to work Angry

So tried to do some debugging but I could not really find an easy way to get some dbug info on screen or in a file. Any suggestions? Thread that I missed?? Angel
Can you post the plugin file here?
(2008-08-21, 08:41 PM)DennisTT Wrote: [ -> ]Can you post the plugin file here?

What is the appropriate way to debug plugins. I have tried generating log files but run in a lot of error messages.... Are there some functions available I can use to make it easier?

Thanks a lot for the support sofar!

EDIT: You have to change the name of the plugin to mailoa.php in order for it to work....
Think i solved it...

when using $user_info['uid'] i get the current user. when using $mybb->input['uid'] I get the user the administrator is working on. and that is the uid I want to send a mail that his account is activated.

so it should be:
$query =$db->simple_select("users", "username, email", "uid=".intval($mybb->input['uid'])."");

I'll post the plugin when it is complete.....
Echo or file_put_contents. In MyBB 1.4 there's an error handling class (inc/class_error.php) if you want to use it to log traces...but it's not really designed for debugging use I think.