2015-01-22, 08:39 AM
Hi.
I am developing a plugin that will restrict the users to change their password and email from the USER CP Menu.
I developed the plugin but it does not work.
When user clicks on the action to edit the password it works fine. If the usergroup has the permission to change the password he can change it otherwise you do not.
The problem now is with the menu on the left side. If user has the permission to edit password the User CP menu "Change Password" does not show up. The code is executed just fine but when it comes to the part to replace the custom template value $changepasswordop it does not work.
Any ideas what is going on?
See below my code.
I am developing a plugin that will restrict the users to change their password and email from the USER CP Menu.
I developed the plugin but it does not work.
When user clicks on the action to edit the password it works fine. If the usergroup has the permission to change the password he can change it otherwise you do not.
The problem now is with the menu on the left side. If user has the permission to edit password the User CP menu "Change Password" does not show up. The code is executed just fine but when it comes to the part to replace the custom template value $changepasswordop it does not work.
Any ideas what is going on?
See below my code.
$plugins->add_hook("usercp_menu", "change_password");
$plugins->add_hook("usercp_password", "password_validate");
function password_activate () {
global $db;
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets('usercp_nav_profile', '#'.preg_quote('<div><a href="usercp.php?action=password" class="usercp_nav_item usercp_nav_password">{$lang->ucp_nav_change_pass}</a></div>').'#', '{$changepasswordop}');
}
function password_deactivate () {
global $db;
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets('usercp_nav_profile', '#{\$changepasswordop}#', '<div><a href="usercp.php?action=password" class="usercp_nav_item usercp_nav_password">{$lang->ucp_nav_change_pass}</a></div>');
}
function change_password() {
global $mybb, $templates, $changepasswordop;
$changepasswordop = '';
if($mybb->usergroup['canchangepassword'] == 1) {
eval("\$changepasswordop = \"".$templates->get("usercp_nav_changepassword")."\";");
}
}
function password_validate() {
global $mybb;
if($mybb->usergroup['canchangepassword'] != 1) {
error_no_permission();
}
}