Preset and lock 'account preferences' ?
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #1
Question Preset and lock 'account preferences' ?
Any way to preset account preferences and lock so user will need to live with the admin reqmts for those settings ?

1. Looked at info about 'Registration Checkbox Configuration' plugin at...
http://mods.mybb.com/view/registration-c...http://mods.mybb.com/view/registration-checkbox-con
...but some reviews were not that great and not sure if can lock the (registration process) preset 'account preferences' or not ?

or...

2. Preset and lock and show checkboxes prechecked (and user cant uncheck)  at registration (so user will know what need to live with), and eliminate 'edit options' at UCP ?

or...

3. Disable checkboxes display and just show list of preferences (during registration) that user will need to live with, and disable (no display) 'edit options' at UCP ?

or... ???

Guess presetting the preferences as default, and then locking them so cant be edited is the main question ?

Is there another plugin or code modification possibility ?

Where to look for info ?

Thanks again for your help !
(This post was last modified: 03-03-2012 02:46 PM by akm.)
03-03-2012 02:45 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #2
RE: Preset and lock 'account preferences' ?
I use the Default profile plugin for my new registrations. I can assign them an avatar etc. If you want to fix the edit options so that the user can never change them then you need to restrict access to this url:

http://path_to_you_forum/usercp.php?action=options

As you can remove the edit options link from the UCP but a user who knows the url can get to it anyway direct. I think that would have to be programmed in. You can try inserting this conditional at the top of the usercp_options template like so:

Code:
1
2
3
4
5
6
7
8
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->edit_options}</title>
{$headerinclude}
</head>
<body>
{$header}
<if in_array($GLOBALS['mybb']->user['usergroup'], array(4)) then>


and at the bottom:

Code:
1
2
3
4
5
6
7
</form>
<else>
ERROR
</if>
{$footer}
</body>
</html>



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 03-03-2012 03:36 PM by leefish.)
03-03-2012 03:11 PM
Visit this user's website Find all posts by this user Quote this message in a reply
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #3
[Update] RE: Preset and lock 'account preferences' ?
(03-03-2012 03:11 PM)leefish Wrote:  I use the Default profile plugin for my new registrations. I can assign them an avatar etc. If you want to fix the edit options so that the user can never change them then you need to restrict access to this url:
http://path_to_you_forum/usercp.php?action=options
As you can remove the edit options link from the UCP but a user who knows the url can get to it anyway direct. I think that would have to be programmed in. Not sure if a conditional can do it.

Thank you for the info !

Was about to update the question and note that only preference would like to lock would be the 'Messaging and Notification' options.

Am able to eliminate registration 'Account Preferences:' display at...
Edit Template: usercp_options.

And take out ucp 'Edit Options' display at...
Edit Template: usercp_nav_profile

But, how to set defaults ?

Seems like maybe at inc/usercp.php (as you mentioned) ?...

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
 if($mybb->input['action'] == "options")
{
	$plugins->run_hooks("usercp_options_start");

	if($errors != '')
	{
		$user = $mybb->input;
	}
	else
	{
		$user = $mybb->user;
	}
	$languages = $lang->get_languages();
	$langoptions = '';
	foreach($languages as $lname => $language)
	{
		$sel = "";
		if($user['language'] == $lname)
		{
			$sel = " selected=\"selected\"";
		}
		$langoptions .= "<option value=\"$lname\"$sel>".htmlspecialchars_uni($language)."</option>\n";
	}

	// Lets work out which options the user has selected and check the boxes
	if($user['allownotices'] == 1)
	{
		$allownoticescheck = "checked=\"checked\"";
	}
	else
	{
		$allownoticescheck = "";
	}

	if($user['invisible'] == 1)
	{
		$invisiblecheck = "checked=\"checked\"";
	}
	else
	{
		$invisiblecheck = "";
	}

	if($user['hideemail'] == 1)
	{
		$hideemailcheck = "checked=\"checked\"";
	}
	else
	{
		$hideemailcheck = "";
	}

	if($user['subscriptionmethod'] == 1)
	{
		$no_email_subscribe_selected = "selected=\"selected\"";
	}
	else if($user['subscriptionmethod'] == 2)
	{
		$instant_email_subscribe_selected = "selected=\"selected\"";
	}
	else

	{
		$no_subscribe_selected = "selected=\"selected\"";
	}

	if($user['showsigs'] == 1)
	{
		$showsigscheck = "checked=\"checked\"";
	}
	else
	{
		$showsigscheck = "";
	}

	if($user['showavatars'] == 1)
	{
		$showavatarscheck = "checked=\"checked\"";
	}
	else
	{
		$showavatarscheck = "";
	}

	if($user['showquickreply'] == 1)
	{
		$showquickreplycheck = "checked=\"checked\"";
	}
	else
	{
		$showquickreplycheck = "";
	}

	if($user['receivepms'] == 1)
	{
		$receivepmscheck = "checked=\"checked\"";
	}
	else
	{
		$receivepmscheck = "";
	}
	
	if($user['receivefrombuddy'] == 1)
	{
		$receivefrombuddycheck = "checked=\"checked\"";
	}
	else
	{
		$receivefrombuddycheck = "";
	}

	if($user['pmnotice'] == 1 || $user['pmnotice'] == 2)
	{
		$pmnoticecheck = " checked=\"checked\"";
	}
	else
	{
		$pmnoticecheck = "";
	}

	if($user['dstcorrection'] == 2)
	{
		$dst_auto_selected = "selected=\"selected\"";
	}
	else if($user['dstcorrection'] == 1)
	{
		$dst_enabled_selected = "selected=\"selected\"";
	}
	else
	{
		$dst_disabled_selected = "selected=\"selected\"";
	}

	if($user['showcodebuttons'] == 1)
	{
		$showcodebuttonscheck = "checked=\"checked\"";
	}
	else
	{
		$showcodebuttonscheck = "";
	}

	if($user['showredirect'] != 0)
	{
		$showredirectcheck = "checked=\"checked\"";
	}
	else
	{
		$showredirectcheck = "";
	}

	if($user['pmnotify'] != 0)
	{
		$pmnotifycheck = "checked=\"checked\"";
	}
	else
	{
		$pmnotifycheck = '';
	}

	
	if($user['threadmode'] != "threaded" && $user['threadmode'] != "linear")
	{
		$user['threadmode'] = ''; // Leave blank to show default
	}

	if($user['classicpostbit'] != 0)
	{
		$classicpostbitcheck = "checked=\"checked\"";
	}
	else
	{
		$classicpostbitcheck = '';
	}


	$date_format_options = "<option value=\"0\">{$lang->use_default}</option>";
	foreach($date_formats as $key => $format)
	{
		if($user['dateformat'] == $key)
		{
			$date_format_options .= "<option value=\"$key\" selected=\"selected\">".my_date($format, TIME_NOW, "", 0)."</option>";
		}
		else
		{
			$date_format_options .= "<option value=\"$key\">".my_date($format, TIME_NOW, "", 0)."</option>";
		}
	}

	$time_format_options = "<option value=\"0\">{$lang->use_default}</option>";
	foreach($time_formats as $key => $format)
	{
		if($user['timeformat'] == $key)
		{
			$time_format_options .= "<option value=\"$key\" selected=\"selected\">".my_date($format, TIME_NOW, "", 0)."</option>";
		}
		else
		{
			$time_format_options .= "<option value=\"$key\">".my_date($format, TIME_NOW, "", 0)."</option>";
		}
	}

	$tzselect = build_timezone_select("timezoneoffset", $mybb->user['timezone'], true);
	
	if($mybb->settings['allowbuddyonly'] == 1)
	{
		eval("\$pms_from_buddys = \"".$templates->get("usercp_options_pms_from_buddys")."\";");
	}

	$threadview[$user['threadmode']] = 'selected="selected"';
	$daysprunesel[$user['daysprune']] = 'selected="selected"';
	$stylelist = build_theme_select("style", $user['style']);
	if($mybb->settings['usertppoptions'])
	{
		$explodedtpp = explode(",", $mybb->settings['usertppoptions']);
		$tppoptions = '';
		if(is_array($explodedtpp))
		{
			foreach($explodedtpp as $key => $val)
			{
				$val = trim($val);
				$selected = "";
				if($user['tpp'] == $val)
				{
					$selected = "selected=\"selected\"";
				}
				$tppoptions .= "<option value=\"$val\" $selected>".$lang->sprintf($lang->tpp_option, $val)."</option>\n";
			}
		}
		eval("\$tppselect = \"".$templates->get("usercp_options_tppselect")."\";");
	}
	if($mybb->settings['userpppoptions'])
	{
		$explodedppp = explode(",", $mybb->settings['userpppoptions']);
		$pppoptions = '';
		if(is_array($explodedppp))
		{
			foreach($explodedppp as $key => $val)
			{
				$val = trim($val);
				$selected = "";
				if($user['ppp'] == $val)
				{
					$selected = "selected=\"selected\"";
				}
				$pppoptions .= "<option value=\"$val\" $selected>".$lang->sprintf($lang->ppp_option, $val)."</option>\n";
			}
		}
		eval("\$pppselect = \"".$templates->get("usercp_options_pppselect")."\";");
	}
	
	$plugins->run_hooks("usercp_options_end");
	
	eval("\$editprofile = \"".$templates->get("usercp_options")."\";");
	output_page($editprofile);
}


...but no idea (if right source) how, if possible, to edit accordingly ?

Would the 'Default profile plugin' (and where to get) work for that, ie preset preferences and then modify usercp.php to limit access to specific part ?

Or, just modify usercp.php  (or another file, [update] like member.php?) to set and eliminate option for user to change preferences ?

Looks like need to do some more T&E on this one !


Thanks again for your help !
(This post was last modified: 03-04-2012 05:28 AM by akm.)
03-04-2012 03:29 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Preset and lock 'account preferences' ?
On the reg form, maybe you can "combine" a dummy fields (disabled) and a hidden fields (unless you don't want to display the fields on the form) by editing the member_register template. Set it checked or not, depends on your default settings. And maybe you need to override the input value if you're not sure whether a user can bypass it or not in member.php
Example:
   
In the scr above, I've checked the 'Hide your email from other members' setting (by default, it is unchecked), and not allowing user to change the value. And I'm not allowing a user to change the 'Receive emails from Administrators' setting.

You can use the similar method for the UserCP.

   

I'm sorry if I misunderstand what you mean.

03-04-2012 07:34 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Preset and lock 'account preferences' ?
Well, for the defaults I edited the default profile plugin then you can edit the member_register template.


[Image: leelink.gif]
MYBB1.6 & XThreads
03-04-2012 09:33 AM
Visit this user's website Find all posts by this user Quote this message in a reply
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #6
RE: Preset and lock 'account preferences' ?
(03-04-2012 07:34 AM)RateU Wrote:  On the reg form, maybe you can "combine" a dummy fields (disabled) and a hidden fields (unless you don't want to display the fields on the form) by editing the member_register template. Set it checked or not, depends on your default settings. And maybe you need to override the input value if you're not sure whether a user can bypass it or not in member.php
Example:
In the scr above, I've checked the 'Hide your email from other members' setting (by default, it is unchecked), and not allowing user to change the value. And I'm not allowing a user to change the 'Receive emails from Administrators' setting.
You can use the similar method for the UserCP.
I'm sorry if I misunderstand what you mean.

Thanks much for the direction !

Preset checkbox/s @ member.php
(add "checked=\"checked\""; to all that want checked)...

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 if(!$fromreg)
		{
			$allownoticescheck = "checked=\"checked\"";
			// $hideemailcheck = '';
			$hideemailcheck = "checked=\"checked\"";
			$emailnotifycheck = '';
			$receivepmscheck = "checked=\"checked\"";
			$pmnoticecheck = " checked=\"checked\"";
			$emailpmnotifycheck = '';
			$invisiblecheck = '';
			if($mybb->settings['dstcorrection'] == 1)
			{
				$enabledstcheck = "checked=\"checked\"";
			}
			
		} 


...and disabled at Edit Template: member_register (after figured out the disabled="disabled" code)...

Code:
 <td valign="top" width="0">
<input type="checkbox" class="checkbox" disabled="disabled" name="allownotices" id="allownotices" value="0" {$allownoticescheck} /></td>
<td valign="top"><span class="smalltext"><label for="allownotices">{$lang->allow_notices}</label></span></td></tr> 


That seems to do it.
Does that seem right ?


Thanks again for your help !
(This post was last modified: 03-04-2012 01:53 PM by akm.)
03-04-2012 01:52 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #7
RE: Preset and lock 'account preferences' ?
Something like that.

For a disabled input fields, if you disable directly the original input, maybe the value of the input fields won't be saved (personally, I don't really like using readonly attribute for a checkboxes). That's why I use an hidden input fields, combined with a dummy input fields.

Something like this (member_register template):

HTML Code
<input type="checkbox" class="checkbox" name="allownoticesdummy" id="allownoticesdummy" value="1" checked="checked" disabled="disabled" />
<input type="hidden" name="allownotices" id="allownotices" value="1" />


Then, set the value in $user['options'] array in member.php (if you're not sure whether a user can change the value of the hidden input fields or not):

PHP Code:
149
"allownotices" => 1,


03-05-2012 05:34 AM
Find all posts by this user Quote this message in a reply
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #8
[Update2] RE: Preset and lock 'account preferences' ?
(03-05-2012 05:34 AM)RateU Wrote:  Something like that.
For a disabled input fields, if you disable directly the original input, maybe the value of the input fields won't be saved (personally, I don't really like using readonly attribute for a checkboxes). That's why I use an hidden input fields, combined with a dummy input fields.
Something like this (member_register template):

HTML Code
<input type="checkbox" class="checkbox" name="allownoticesdummy" id="allownoticesdummy" value="1" checked="checked" disabled="disabled" />
<input type="hidden" name="allownotices" id="allownotices" value="1" />

Then, set the value in $user['options'] array in member.php (if you're not sure whether a user can change the value of the hidden input fields or not):

PHP Code:
149
"allownotices" => 1,


Thank you for the info !
Display is fine now (scrnshot attached), but when go to user profile, the resulting default options are not as set (scrnshot attached).

Modified code...

Code:
1
2
3
4
5
6
7
8
9
10
[$user['options'] = array(
		"allownotices" =>1,		
		"hideemail" =>1,		
		"subscriptionmethod" =>1,		
		"receivepms" =>1,		
		"pmnotice" =>1, 		
		"emailpmnotify" =>1,		
		"invisible" =>1,		
		"dstcorrection" =>1
	);

...but not sure what it is actually doing for setting options, but have removed the Edit Options button from the UCP (scrnshot attached), so assume that should eliminate the ability to change options ?

Any suggestions on where should look to set the actual options so they take effect at the profile display ?
Would like user to accept messages and have email notice, but not be able to be emailed directly by other users.

Ps:
Took out Email: field at member_profile, so not displayed, now how to get PM link to display ?
'member_profile' for PM looks like...

Code:
<tr>
<td class="{$bgcolors['pm']}"><strong>{$lang->pm}</strong></td>
<td class="{$bgcolors['pm']}"><a href="private.php?action=send&amp;uid={$memprofile['uid']}">{$lang->send_pm}</a></td>
</tr>

PM is showing up for one user, source view...

Code:
<tr>
<td class="trow2"><strong>Private Message:</strong></td>
<td class="trow2"><a href="private.php?action=send&amp;uid=3">Send akmyah a private message.</a></td>
</tr>

but not in another, source view...

Code:
<tr>
<td class="trow1"><strong>Private Message:</strong></td>
<td class="trow1"><a href="private.php?action=send&amp;uid=14"></a></td>
</tr>

...looks like some 'lang' missing somehow ?
Admin looks at account settings, shows one has boxes checked and other does not.
Isnt the (add "checked=\"checked\""; supposed to take care of that ?

Ps2:
Have tried three more test registrations, and all are per the pre-checked settings.
Now wondering how one got thru without.
Deleted and re-registered subject user and still not showing PM... wonder what it is about the one user that goes against the preset options ?
Guess just need to wait and see... few more tests ?



Attached File(s) Thumbnail(s)
           

Thanks again for your help !
(This post was last modified: 03-15-2012 09:27 AM by akm.)
03-15-2012 05:41 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #9
RE: Preset and lock 'account preferences' ?
(03-15-2012 05:41 AM)akm Wrote:  but have removed the Edit Options button from the UCP (scrnshot attached), so assume that should eliminate the ability to change options ?

(03-04-2012 07:34 AM)RateU Wrote:  You can use the similar method for the UserCP.

03-16-2012 05:20 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: