Log in

View Full Version : Force user to accept (Enable) Private Messages


teonix
07-13-2005, 09:28 PM
I'm trying to make it so that Private Messages are always enabled for every user. (The user can't be allowed to disable them).

I can't comment out the checkbox because then it thinks the user has PM's disabled.

I also still want the user to be able to enable/disable email notifications of PM's and pop-up notifications while browsing.

Any ideas?


The code for the display of the options, can be found in the "modifyoptions" template and looks like this:


<if condition="$show['pmoptions']">
<fieldset class="fieldset">
<legend><label for="cb_receivepm">$vbphrase[private_messaging]</label></legend>
<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%">

<tr>
<td>
<phrase 1="private.php?$session[sessionurl]">$vbphrase[features_private_messaging_system]</phrase>
</td>
</tr>

<tr>
<td><label for="cb_receivepm"><input type="checkbox" name="options[receivepm]" value="1" id="cb_receivepm" onclick="toggle_disabled(this.checked, 'pmoptions')" $checked[receivepm] />$vbphrase[enable_private_messaging]</label></td>
</tr>

<tbody id="pmoptions"<if condition="!$bbuserinfo[receivepm]"> disabled="disabled"</if>>

<tr>
<td><br />$vbphrase[can_email_when_sends_you_pm]</td>
</tr>

<tr>
<td><label for="cb_emailonpm"><input type="checkbox" name="options[emailonpm]" value="1" id="cb_emailonpm" $checked[emailonpm] />$vbphrase[receive_email_notification_pm]</label></td>
</tr>

<tr>
<td><br /><br />$vbphrase[browsing_when_receive_pm_popup]</td>
</tr>

<tr>
<td><label for="cb_pmpopup"><input type="checkbox" name="pmpopup" value="1" id="cb_pmpopup" $checked[pmpopup] />$vbphrase[show_pm_popup]</label></td>
</tr>
</tbody>
</table>
</fieldset>
<else />
<input type="hidden" name="options[receivepm]" value="$bbuserinfo[receivepm]" />
<input type="hidden" name="options[emailonpm]" value="$bbuserinfo[emailonpm]" />
<input type="hidden" name="pmpopup" value="$bbuserinfo[pmpopup]" />
</if>

teonix
07-15-2005, 03:43 PM
Does anyone have any suggestions? :)

tamarian
07-15-2005, 04:17 PM
I don't think this is doable through a template change.

teonix
07-16-2005, 04:24 PM
Not at all? :(

Could it work to replace the checkbox with a hidden input field that passes along the "enabled" status?

tamarian
07-16-2005, 04:38 PM
Not at all? :(

Could it work to replace the checkbox with a hidden input field that passes along the "enabled" status?

Actually, that should work. Have you tried it?

teonix
07-17-2005, 06:55 AM
I'll give it a shot, I might need some help, but i'll see what I can do first and
i'll get back to you

I think I got it working, just wanted to confirm if I did it right in your opinion..


Old Code (Checkbox):

<input type="checkbox" name="options[receivepm]" value="1" id="cb_receivepm" onclick="toggle_disabled(this.checked, 'pmoptions')" $checked[receivepm] />



New Code (Hidden Input):

<input type="hidden" name="options[receivepm]" value="1" id="cb_receivepm" />

Guest190829
07-17-2005, 09:16 AM
It looks fine to me. :)

Andreas
07-17-2005, 10:31 AM
Using a hidden field will not stop Users from disabling PM.

But this should:

$_POST['options']['receivepm'] = 1;


in phpinclude_start.

teonix
07-17-2005, 03:52 PM
Oh, interesting.. thank you for that information, i'll make that change right away..

If its not too much trouble though, could you briefly explain why the hidden field won't and what the code you gave does differently to prevent it?

Thanks very much.

Andreas
07-17-2005, 05:31 PM
Well, a Hidden field sets the Form-Value to 1. So when the Users submits the Form it will be one.
But as this is being done at the Client Side, you can never be sure that the User will be submitting this Form - he could just use his own one where the Value is 0.
My Code sets the Value to 1 at server side, so the User has no chance to cheat.

teonix
07-17-2005, 05:57 PM
Perfect :) Very helpful explanation.. thank you very much :)

So after adding $_POST['options']['receivepm'] = 1;

into phpinclude_start


What do you suggest I do with the options in the user control panel? leave the hidden field? Or remove the field entirely and just leave the other two options (receive notification, and receive popup)?

Andreas
07-17-2005, 06:04 PM
Leave it as it is, remove it, make it a hidden field - doesn't matter :)

teonix
07-17-2005, 06:13 PM
okay cool :)

Thank you very much.

tamarian
07-17-2005, 07:23 PM
No, I take that back, it should be o.k. :) Mods don't have a choice, but admins can do it for them.

There's still one problem with doing it in phpinclude_start

Admins and mods on busy forums frequently disable their own PM's, sicne they get bombarded by regular questions through PM by newbies who don't want to post.

If you want to allow admins and moderators to have a choice, it won't work with the phpinclude method, even if you edit their profile for them in the admin panel. Meaning they can't disable it, and even you can't disable it for them.

If you still want to allow the choice for some usergroups like admins and mods, then hidden fields should do. You're not likely to find members going through the effort to change hidden fields, even if they knew how. :)

basketmen
03-18-2011, 09:59 PM
Using a hidden field will not stop Users from disabling PM.

But this should:

$_POST['options']['receivepm'] = 1;


in phpinclude_start.
i am sorry guys to bump very old thread, since i am still dong get the answer for this basic thing :

- is it phpinclude_start is a template? i am using vb 3.6.12 and dont have this template, should i create it as new custom template?

- is there easier methode than this one?
it is not good to allow members disabled they PM, how moderator/admin can contact them then? specially when want to tell the members that break the forum rules

Lynne
03-18-2011, 11:25 PM
Yes, it was a template. No, you shouldn't just create it since there is nowhere in the code that it would get evaled. I suppose you could try global_start, but I really don't know since I don't have a copy of 3.6 to test.

You may be able to force the PM system on, but that doesn't mean you can actually force them to read the PM.