Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: [SiNaN] on August 18, 2008, 11:23:54 AM

Title: Change Account Status From Profile
Post by: [SiNaN] on August 18, 2008, 11:23:54 AM
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.
Title: Re: Change Account Status From Profile
Post by: ccbtimewiz on August 18, 2008, 11:45:01 AM
You might want to make this an admin thing only.

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

http://www.simplemachines.org/community/index.php?topic=282778.0
Title: Re: Change Account Status From Profile
Post by: chrisb on December 28, 2008, 05:47:05 PM
With this mod, you can always add more options


1. Re Activatation
2. Suspended
3. Pending Activation


here are my ideas
Title: Re: Change Account Status From Profile
Post by: chrisb on December 28, 2008, 05:54:09 PM
                        <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>
Title: Re: Change Account Status From Profile
Post by: BuЯЯЯЯaK on December 31, 2008, 06:37:34 AM
Thanks Sinan :)
Title: Re: Change Account Status From Profile
Post by: enjoy1985 on January 20, 2009, 10:03:03 PM
Great tip.
Thanks
Title: Re: Change Account Status From Profile
Post by: R.Bourne on October 29, 2009, 03:13:49 AM
On version 1.1.0, the BANNED member shows as "Pending"! What's the point of this tip or I'm missing something :)
Title: Re: Change Account Status From Profile
Post by: Kill Em All on February 07, 2010, 09:38:56 PM

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