Question: How do I activate/deactivate the account from profile? (by default you can only activate)
Original Topic: http://www.simplemachines.org/community/index.php?topic=255463.0
Profile.php
Find:
'secret_question' => !isset($user_profile[$memID]['secretQuestion']) ? '' : $user_profile[$memID]['secretQuestion'],
Replace:
'secret_question' => !isset($user_profile[$memID]['secretQuestion']) ? '' : $user_profile[$memID]['secretQuestion'],
'is_activated' => !isset($user_profile[$memID]['is_activated']) ? '0' : $user_profile[$memID]['is_activated'],
Find:
// Now call the sub-action function...
Replace:
// Maybe we are changing the account status?
if($user_info['is_admin'] && isset($_POST['account_status']))
$profile_vars['is_activated'] = $_POST['account_status'];
// Now call the sub-action function...
Profile.template.php
Find:
<td><input type="text" name="posts" size="4" value="', $context['member']['posts'], '" /></td>
Replace:
<td><input type="text" name="posts" size="4" value="', $context['member']['posts'], '" /></td>
</tr>
<tr>
<td><b>Account Status: </b></td>
<td>
<select name="account_status">
<option value="0"', $context['member']['is_activated'] == 0 ? ' selected="selected"' : '', '>Pending</option>
<option value="1"', $context['member']['is_activated'] == 1 ? ' selected="selected"' : '', '>Activated</option>
</select>
</td>
Setting will appear under account settings.
You might want to make this an admin thing only.
So, use $context['user']['is_admin'] as a conditional around the Account Status field.
That is an admin thing already. You can't find bugs, he he. :P
No I mean, if the user isn't an admin and they are the owner of the account, they can see this is_activated setting. :P
They can't see it. Check where I add the field. Can you change your own post count?
Quote from: [SiNaN] on August 18, 2008, 11:56:12 AM
They can't see it. Check where I add the field. Can you change your own post count?
Well that's what I'm saying. If the user has permission to change their post count, then they see their activated status. :P
If the user is not admin, he can't have the change post count permission.
I stand corrected. :P
You just spammed. :P
I could say the same to you. Mr. Ten Thousand Tips and Tricks man :P
Sinan, how do you do this for SMF 2.0?
For SMF 2.0 Beta 4:
../Sources/Profile-Modify.php
Find:
'secret_question', 'secret_answer',
Replace:
'secret_question', 'secret_answer', 'is_activated',
Find:
'real_name' => array(
Replace:
'is_activated' => array(
'type' => 'select',
'cast_type' => 'int',
'options' => 'return array(0 => \'Pending\', 1 => \'Activated\');',
'label' => 'Account Status',
'permission' => 'moderate_forum',
),
'real_name' => array(
Worked like a charm, thanks. :)
Question..
Isnt this a lang issue normally? I looked at the code and it turns out this is where the addition is for this alteration.
Undefined index: is_activated
File: /forum/Themes/default/Profile.template.php (eval?)
Line: 1341
Make sure you've done the first edit correctly.
this is now a mod
http://www.simplemachines.org/community/index.php?topic=282778.0
With this mod, you can always add more options
1. Re Activatation
2. Suspended
3. Pending Activation
here are my ideas
<td><input type="text" name="posts" size="4" value="', $context['member']['posts'], '" /></td>
</tr>
<tr>
<td><b>Account Status: </b></td>
<td>
<select name="account_status">
<option value="0"', $context['member']['is_activated'] == 0 ? ' selected="selected"' : '', '>Pending</option>
<option value="1"', $context['member']['is_activated'] == 1 ? ' selected="selected"' : '', '>Activated</option>
<option value="2"', $context['member']['is_activated'] == 2 ? ' selected="selected"' : '', '>Suspended</option>
</select>
</td>
Thanks Sinan :)
Great tip.
Thanks
On version 1.1.0, the BANNED member shows as "Pending"! What's the point of this tip or I'm missing something :)
<td><input type="text" name="posts" size="4" value="', $context['member']['posts'], '" /></td>
</tr>
<tr>
<td><b>Account Status: </b></td>
<td>
<select name="account_status">
<option value="0"', $context['member']['is_activated'] == 0 ? ' selected="selected"' : '', '>Pending</option>
<option value="1"', $context['member']['is_activated'] == 1 ? ' selected="selected"' : '', '>Activated</option>
</select>
</td>
Check out that bit of code, you can change the text in there probably.