MyBB Hacks

Full Version: Preset and lock 'account preferences' ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ?
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:
<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:
</form>
<else>
ERROR
</if>
{$footer}
</body>
</html>

(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:
 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 !

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:
[attachment=711]
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.

[attachment=712]

I'm sorry if I misunderstand what you mean.
Well, for the defaults I edited the default profile plugin then you can edit the member_register template.
(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:
 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 ?

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:
"allownotices" => 1,

(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:
"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:
[$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 ?

(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.
Reference URL's