Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: [SiNaN] in August 18, 2008, 11:23:54 VORMITTAG

Titel: Change Account Status From Profile
Beitrag von: [SiNaN] in August 18, 2008, 11:23:54 VORMITTAG
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.
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in August 18, 2008, 11:45:01 VORMITTAG
You might want to make this an admin thing only.

So, use $context['user']['is_admin'] as a conditional around the Account Status field.
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in August 18, 2008, 11:47:30 VORMITTAG
That is an admin thing already. You can't find bugs, he he. :P
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in August 18, 2008, 11:52:50 VORMITTAG
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
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in August 18, 2008, 11:56:12 VORMITTAG
They can't see it. Check where I add the field. Can you change your own post count?
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in August 18, 2008, 11:58:02 VORMITTAG
Zitat von: [SiNaN] in August 18, 2008, 11:56:12 VORMITTAG
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
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in August 18, 2008, 12:01:25 NACHMITTAGS
If the user is not admin, he can't have the change post count permission.
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in August 18, 2008, 12:02:51 NACHMITTAGS
I stand corrected.  :P
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in August 18, 2008, 12:05:02 NACHMITTAGS
You just spammed. :P
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in August 18, 2008, 12:13:43 NACHMITTAGS
I could say the same to you. Mr. Ten Thousand Tips and Tricks man  :P
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in Oktober 01, 2008, 06:47:25 NACHMITTAGS
Sinan, how do you do this for SMF 2.0?
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in Oktober 01, 2008, 07:04:11 NACHMITTAGS
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(
Titel: Re: Change Account Status From Profile
Beitrag von: ccbtimewiz in Oktober 01, 2008, 07:10:33 NACHMITTAGS
Worked like a charm, thanks. :)
Titel: Re: Change Account Status From Profile
Beitrag von: HR in Dezember 16, 2008, 10:00:03 VORMITTAG
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
Titel: Re: Change Account Status From Profile
Beitrag von: [SiNaN] in Dezember 17, 2008, 03:03:28 VORMITTAG
Make sure you've done the first edit correctly.
Titel: Re: Change Account Status From Profile
Beitrag von: Deaks in Dezember 28, 2008, 01:16:07 NACHMITTAGS
this is now a mod

http://www.simplemachines.org/community/index.php?topic=282778.0
Titel: Re: Change Account Status From Profile
Beitrag von: chrisb in Dezember 28, 2008, 05:47:05 NACHMITTAGS
With this mod, you can always add more options


1. Re Activatation
2. Suspended
3. Pending Activation


here are my ideas
Titel: Re: Change Account Status From Profile
Beitrag von: chrisb in Dezember 28, 2008, 05:54:09 NACHMITTAGS
                        <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>
Titel: Re: Change Account Status From Profile
Beitrag von: BuЯЯЯЯaK in Dezember 31, 2008, 06:37:34 VORMITTAG
Thanks Sinan :)
Titel: Re: Change Account Status From Profile
Beitrag von: enjoy1985 in Januar 20, 2009, 10:03:03 NACHMITTAGS
Great tip.
Thanks
Titel: Re: Change Account Status From Profile
Beitrag von: R.Bourne in Oktober 29, 2009, 03:13:49 VORMITTAG
On version 1.1.0, the BANNED member shows as "Pending"! What's the point of this tip or I'm missing something :)
Titel: Re: Change Account Status From Profile
Beitrag von: Kill Em All in Februar 07, 2010, 09:38:56 NACHMITTAGS

                        <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.