Advertisement:

Author Topic: Change Account Status From Profile  (Read 34583 times)

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Change Account Status From Profile
« 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:

Code: [Select]
'secret_question' => !isset($user_profile[$memID]['secretQuestion']) ? '' : $user_profile[$memID]['secretQuestion'],
Replace:

Code: [Select]
'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:

Code: [Select]
// Now call the sub-action function...
Replace:

Code: [Select]
// 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:

Code: [Select]
<td><input type="text" name="posts" size="4" value="', $context['member']['posts'], '" /></td>
Replace:

Code: [Select]
<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.
« Last Edit: August 18, 2008, 11:55:28 AM by [SiNaN] »
Former SMF Core Developer | My Mods | SimplePortal

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #1 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.

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #2 on: August 18, 2008, 11:47:30 AM »
That is an admin thing already. You can't find bugs, he he. :P
Former SMF Core Developer | My Mods | SimplePortal

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #3 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

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #4 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?
Former SMF Core Developer | My Mods | SimplePortal

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #5 on: August 18, 2008, 11:58:02 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

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #6 on: August 18, 2008, 12:01:25 PM »
If the user is not admin, he can't have the change post count permission.
Former SMF Core Developer | My Mods | SimplePortal

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #7 on: August 18, 2008, 12:02:51 PM »
I stand corrected.  :P

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #8 on: August 18, 2008, 12:05:02 PM »
You just spammed. :P
Former SMF Core Developer | My Mods | SimplePortal

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #9 on: August 18, 2008, 12:13:43 PM »
I could say the same to you. Mr. Ten Thousand Tips and Tricks man  :P

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #10 on: October 01, 2008, 06:47:25 PM »
Sinan, how do you do this for SMF 2.0?

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #11 on: October 01, 2008, 07:04:11 PM »
For SMF 2.0 Beta 4:

../Sources/Profile-Modify.php

Find:

Code: [Select]
'secret_question', 'secret_answer',
Replace:

Code: [Select]
'secret_question', 'secret_answer', 'is_activated',
Find:

Code: [Select]
'real_name' => array(
Replace:

Code: [Select]
'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

Offline ccbtimewiz

  • SMF Hero
  • ******
  • Posts: 5,300
  • Gender: Male
  • OXEN
Re: Change Account Status From Profile
« Reply #12 on: October 01, 2008, 07:10:33 PM »
Worked like a charm, thanks. :)

Offline HR

  • Jr. Member
  • **
  • Posts: 321
  • Gender: Male
  • There is only ONE 'Reality!
    • http://only-harshreality.com/forums/
Re: Change Account Status From Profile
« Reply #13 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
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.

Offline [SiNaN]

  • SMF Super Hero
  • *******
  • Posts: 11,524
  • Young and Foolish
    • SimplePortal
Re: Change Account Status From Profile
« Reply #14 on: December 17, 2008, 03:03:28 AM »
Make sure you've done the first edit correctly.
Former SMF Core Developer | My Mods | SimplePortal

Offline BryanD

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,019
  • Gender: Male
    • BryanRunicDeakin on Facebook
    • @bryandeakin on Twitter
    • Bryan Deakin dot Com
Re: Change Account Status From Profile
« Reply #15 on: December 28, 2008, 01:16:07 PM »

Offline chrisb

  • Jr. Member
  • **
  • Posts: 214
Re: Change Account Status From Profile
« Reply #16 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

Offline chrisb

  • Jr. Member
  • **
  • Posts: 214
Re: Change Account Status From Profile
« Reply #17 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>

Offline BuЯЯЯЯaK

  • SMF Hero
  • ******
  • Posts: 2,121
  • Gender: Male
  • Burak
    • dinle sevgili
Re: Change Account Status From Profile
« Reply #18 on: December 31, 2008, 06:37:34 AM »
Thanks Sinan :)