MyBB Community Forums

Full Version: Ban-Unban links in User Profiles
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
You might have noticed a link Ban this user in Mod CP in user profile. If you ban a user, the link still says the same Ban this user in ModCP. However the user is already banned Undecided I've reported this bug here: http://community.mybb.com/thread-88947.html . There is a small fix for this so I thought to share it with the community. Wink

Go to ./member.php and find; (around line # 1752)
		else
		{
			$memprofile['usernotes'] = $lang->no_usernotes;
		}

and add the following code just after that;
		if ($memprofile['usergroup'] != 7)
		{
			$ban_unban = "<li><a href=\"{$mybb->settings['bburl']}/modcp.php?action=banuser&amp;uid={$uid}\">{$lang->ban_in_mcp}</a></li>";
		}
		else
		{
			$ban_unban = "<li><a href=\"{$mybb->settings['bburl']}/modcp.php?action=liftban&amp;uid={$uid}&amp;my_post_key={$mybb->post_code}\">{$lang->unban_in_mcp}</a></li>";
		}
		if ($memprofile['uid'] == $mybb->user['uid'])
		{
			$ban_unban = "";
		}

Now Go to: Admin CP > Templates > *Your theme's templates* > Member Templates > member_profile_modoptions > and find;
<li><a href="{$mybb->settings['bburl']}/modcp.php?action=banuser&amp;uid={$uid}">{$lang->ban_in_mcp}</a></li>

and Replace it to;
{$ban_unban}

Now Go to: ./inc/languages/english/member.php and find;
$l['ban_in_mcp'] = "Ban this user in Mod CP";
and add the following just after that;
$l['unban_in_mcp'] = "Unban this user in Mod CP";

Similarly, if you want to change the link in Administrator Options options box, then here is how;

Open ./member.php and find; (around line # 1734)
		eval("\$adminoptions = \"".$templates->get("member_profile_adminoptions")."\";");

and add the following code just above that;
		if ($memprofile['usergroup'] != 7)
		{
			$ban_unban = "<li><a href=\"{$mybb->settings['bburl']}/{$config['admin_dir']}/index.php?module=user/banning&amp;uid={$uid}\">{$lang->admin_ban_in_acp}</a></li>";
		}
		else
		{
			$ban_unban = "<li><a href=\"{$mybb->settings['bburl']}/{$config['admin_dir']}/index.php?module=user-banning&action=lift&uid={$uid}&amp;my_post_key={$mybb->post_code}\">{$lang->admin_unban_in_acp}</a></li>";
		}
		if ($memprofile['uid'] == $mybb->user['uid'])
		{
			$ban_unban = "";
		}

Now Go to: Admin CP > Templates > *Your theme templates* > Member Templates > member_profile_adminoptions > and find;
<li><a href="{$mybb->settings['bburl']}/{$config['admin_dir']}/index.php?module=user/banning&amp;uid={$uid}">{$lang->admin_ban_in_acp}</a></li>

and Replace it to;
{$ban_unban}

No Go to: ./inc/languages/english/member.php and find;
$l['admin_ban_in_acp'] = "Ban this user in Admin CP";
and add the following code just below that;
$l['admin_unban_in_acp'] = "Unban this user in Admin CP";

Save the files and templates and the bug corrected Wink

OLD:
[attachment=21710] [attachment=21712]
NEW:
[attachment=21711] [attachment=21713]
I want to begin by apologizing profusely for grave digging this post - especially considering how old it is.

I then want to thank Yaldaram for an excellent contribution - because this is exactly what I was looking for.