Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: [SAP]Francis on August 13, 2008, 04:40:43 PM

Title: How to add a new profile field for admins?
Post by: [SAP]Francis on August 13, 2008, 04:40:43 PM
I want to be able to set if a user is activated or not (is_activated field in members database.) in the Account Settings of members in their profiles. Which will activate or deactivate them.

How? :)
Title: Re: How to add a new profile field for admins?
Post by: [SiNaN] on August 14, 2008, 08:35:49 AM
Actually you have that option both in Profile and Admin CP for not activated accounts. So you also want to deactivate accounts?
Title: Re: How to add a new profile field for admins?
Post by: [SAP]Francis on August 14, 2008, 11:39:55 AM
You're right, Sinan. That's what I want ;)
Title: Re: How to add a new profile field for admins?
Post by: metallica48423 on August 15, 2008, 01:48:00 AM
Probably wouldn't be too hard to set up a link for it.  if you're looking for someone to do it i'd reccommend Mod Requests (http://www.simplemachines.org/community/index.php?board=79.0) or Help Wanted (not for support) (http://www.simplemachines.org/community/index.php?board=50.0)

seems like a simple query to do as well.

just add an action/subaction
check the permission for member management and check the session to make sure its not forged before its done
probably a js popup that asks if you're sure

Title: Re: How to add a new profile field for admins?
Post by: [SAP]Francis on August 15, 2008, 01:57:57 AM
Nah, not a link, only a drop down box only seen by admins where when you press save, it updates the database. That's not hard, I just need to know what files to edit.
Title: Re: How to add a new profile field for admins?
Post by: metallica48423 on August 15, 2008, 01:59:24 AM
I believe it'd be profile.template.php if its part of the profiles.  AFAIk that file does templating for all the template areas
Title: Re: How to add a new profile field for admins?
Post by: [SAP]Francis on August 15, 2008, 02:02:16 AM
Well, is it Profile.php in sources when you press "Save"? :-\
Title: Re: How to add a new profile field for admins?
Post by: metallica48423 on August 15, 2008, 02:07:02 AM
Yes, it would be, however, Profile.php doesn't actually display anything.  SMF's theming system seperates the actual work of gathering and preparing data between the Sources and the Themes.

So to actually display something you'd edit the template.  To do any data manipulation you'd want to edit the Profile.php.
Title: Re: How to add a new profile field for admins?
Post by: [SiNaN] on August 15, 2008, 10:23:11 AM
Well, shouldn't be hard.

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