MyBB Community Forums

Full Version: Close Account Button (ACP Form Help)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
By the way, with forms I was told just to use inspect element and find the forum source code. I'm using the following code to set a user to a group called closed, bans that never expire basically.

<if $mybb->user['usergroup'] == 4 then>
<form action="index.php?module=user-users&amp;action=edit&amp;uid={$member['uid']}" method="post" enctype="multipart/form-data">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="usergroup" value="9" />
<input type="submit" value="Close Account" class="button" />
</form>
</if>

Doesn't seem to be working properly though. It's on a member profile. The button is there, but it just redirects me to the homepage and doesn't do anything to the account.

Destroy666's reply to me in another thread:
Quote:Please don't stack up multiple issues in one thread (create new), it started to become a mess because we don't answer anything relevant to the original question.

Anyways, this is a back-end ACP action and you're leading to front-end index.php which doesn't have it.
Additionally, it's {$memprofile['uid']}, not {$member['uid']} and you need to add all required fields to form or there will be an error like: "You did not enter a username. Please enter one."

What would be the correct method of doing this then? I just want to change their usergroup to Closed. Only administrators can perform this action.
Not sure what you didn't understand, but I'll list the required changes again:
1. Change action to correct path. index.php... is front-end, you need admin/index.php... for back-end (replace admin with correct ACP folder if you renamed it).
2. Change {$member['uid']} to {$memprofile['uid']}
3. Add required hidden inputs (marked in user edit page with *), so for example username (current value {$memprofile['username']}) or E-mail (value {$memprofile['email']})

Please be more specific about further issues.
(2014-06-09, 05:27 PM)Destroy666 Wrote: [ -> ]Not sure what you didn't understand, but I'll list the required changes again:
1. Change action to correct path. index.php... is front-end, you need admin/index.php... for back-end (replace admin with correct ACP folder if you renamed it).
2. Change {$member['uid']} to {$memprofile['uid']}
3. Add required hidden inputs (marked in user edit page with *), so for example username (current value {$memprofile['username']}) or E-mail (value {$memprofile['email']})

Please be more specific about further issues.

Apologies, I've gotten it a bit narrower.

<if $mybb->user['usergroup'] == 4 then>
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td colspan="1" class="thead"><strong>Administrative Actions</strong></td>
</tr>
<tr>
<td class="trow1">
<form action="admindir/index.php?module=user-users&amp;action=edit&amp;uid={$memprofile['uid']}" method="post" enctype="multipart/form-data">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<input type="hidden" name="username" value="{$memprofile['username']}" />
<input type="hidden" name=email" value="$memprofile['email']}" />
<input type="hidden" name="displaygroup" value="9" />
<input type="hidden" name="postcount" value="{$memprofile['postnum']}" />
<input type="hidden" name="usergroup" value="9" />
<input type="submit" value="Close Account" class="button" />
</form>
</td>
</tr>
</table>
</if>

My first guess is that the names for displaygroup and postcount are incorrect, however even when removing them I can't see the member.php profiles, they just go blank.

To confirm, the issue is that the page is white and doesn't load when that code is on it. No idea what's wrong in it, other than the possible incorrect values (which were removed and I've tried with that).
Well, you got improper syntax in your code:
name=email" (" missing)
value="$memprofile['email']}" ({ missing)
thus you get a blank page.
Perfect, thank you! Two final issues.
1. It redirects to admincp when done, any way to process the form but not redirect to ACP?
2. Any way to display it as text instead of a button?

By the way, thank you very much for putting up with me Smile You're a great help.
1. I don't think so. ACP has its own sessions, so you may need to login as well if your last session had ended.

2. Yes. Just edit HTML. Instead of the submit button use:
<a href="javascript:closeAccount.submit();">Close Account</a>
and add this attribute to <form>:
name="closeAccount"

Also, you don't need this enctype when the form doesn't deal with files.

No problem.
Final thing, instead of having a plugin and the file hook stuff, can't I just make a template for it and use $mybb->xxx whatever the get template one is?