MyBB Community Forums

Full Version: Enable private message email notify on member registration by default
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My first question here and apologies if it's been covered before. I can find quite a few threads on similar subjects but not quite the same.  MyBB version is 1.8.3 but it occurred with previous ones.

I find when a new user registers that 'Notify me by email when I receive a new Private Message' is unchecked by default. I'm a little confused with this as the template code in the Default Templates member_register is:

<td valign="top" width="1"><input type="checkbox" class="checkbox" name="pmnotify" id="pmnotify" value="1" {$pmnotifycheck} /></td>
<td valign="top"><span class="smalltext"><label for="pmnotify">{$lang->email_notify_newpm}</label></span></td>

Now I'm guessing the 'value="1"' in the first line is setting the default value to be 1 and therefore checked? But why is it showing unchecked?  I don't want to hardcode the checkbox to be checked (as suggested in previous posts) as when I do that it appears a user can't uncheck it on registration.

I basically want 'Notify me by email when I receive a new Private Message.' to be checked by default on the new member registration form, but with the option for the prospective user to uncheck it on the same form.
Excuse, wrong solution for your problem has been removed.
UPDATE `mybb_users` SET  `pmnotify'  = '1'  WHERE  `pmnotify'  = '0';

ALTER TABLE  `mybb_users`  CHANGE  `pmnotify'  `pmnotify'  tinyint(1)  NOT NULL  default '1';

SQL query guidance
Cheers - but won't that just change the pmnotify for existing users? I realise I'll have to run that at some point, but I want to make the default value of 'Notify me by email when I receive a new Private Message' to be checked when a new user registers as opposed to the default unchecked.
I understand that the second query should do what you want, but it did not work with me. A very simple plugin does:

<?php
/**
 * Disallow direct access to this file for security reasons 
 * 
 */
if(!defined("IN_MYBB")) 
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("member_register_end", "set_pmnotify_to_1");
/**
 * Standard MyBB info function
 * 
 */
function set_pmnotify_to_1_info()
{
    global $lang;
    return Array(
        'name'          => "set_pmnotify_to_1",
        'description'   => "test een plugin",
        'website'       => '',
        'author'        => 'Ad Bakker',
        'authorsite'    => '',
        'version'       => '1.0',
        'guid'          => '',
        'compatibility' => '18*',
    );
}

function set_pmnotify_to_1()
{
	global $pmnotifycheck;
	$pmnotifycheck = " checked=\"checked\"";
}
?>

I tried it, and the check box is checked now!!
why not just replace "{$pmnotifycheck}" with checked="checked"
You are completely right, changing line 68 of template member_register to:

<td valign="top" width="1"><input type="checkbox" class="checkbox" name="pmnotify" id="pmnotify" value="1" checked="checked" /></td>


does the job.
I was still thinking of a similar problem of a default setting that was not at the registration form.
And of course: why do it simple when it can be done in a difficult way Big Grin .
Ah, that does work - thank you! I have to admit I saw this already but for some reason I assumed a user wouldn't be able to uncheck it. That'll teach me to try it first. Duh.

Thanks!