Change Account Status From Profile

Started by [SiNaN], August 18, 2008, 11:23:54 AM

Previous topic - Next topic

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

You might want to make this an admin thing only.

So, use $context['user']['is_admin'] as a conditional around the Account Status field.

[SiNaN]

That is an admin thing already. You can't find bugs, he he. :P
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

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

[SiNaN]

They can't see it. Check where I add the field. Can you change your own post count?
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

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

[SiNaN]

If the user is not admin, he can't have the change post count permission.
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz


[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

I could say the same to you. Mr. Ten Thousand Tips and Tricks man  :P

ccbtimewiz

Sinan, how do you do this for SMF 2.0?

[SiNaN]

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(
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz


HR

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

I can explain this as simply as possible.. If I do it & implement I guarantee it.
If I do it and you implement it its a crap shoot.

[SiNaN]

Make sure you've done the first edit correctly.
Former SMF Core Developer | My Mods | SimplePortal

Deaks

~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

chrisb

With this mod, you can always add more options


1. Re Activatation
2. Suspended
3. Pending Activation


here are my ideas

chrisb

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

BuЯЯЯЯaK



Advertisement: