News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Hi, and can you help a new forum admin?

Started by dsmclaughlin22, March 18, 2015, 04:43:08 AM

Previous topic - Next topic

dsmclaughlin22

Hi All,

I'm new here, new to SMF and a new volunteer forum admin for a local club. Someone figured out I have a history with software development and so I've been tasked with building a new forum for the club.

It's going well, so far I have managed to install successfully and have got to grips with the basics and I must say, I'm really impressed with the quality of SMF it's excellent, especially compared to the old forum the club uses! However, now I'd like to implement more complicated functionality and I need a little help.

I've been searching thorough this forum, available mods and online documentation, but I can't find anything that fits the bill exactly.

The new forum works by letting anyone sign up, these 'Public' members can only see a few boards but if they pay their club membership fee (to the club membership secretary, offline) they are upgraded to 'Club' members can see all the boards. I have figured out how to give boards different permissions and how to change user types so this par is fine.

The next bit is the complicated bit:

Users have a set of custom fields, these need to be optional for a 'Public' member but once a member is upgraded to being a 'Club' member these fields become mandatory.

Is there some way I can force the user to update their profile with the mandatory information on first login as a 'Club' member but not force them to add this information when they are a 'Public' member?

Many thanks, any suggests gratefully received!

~Drew

Illori

in SMF by default that can not be done, you would need a mod. i dont know of any that exist that will do what you want.

dsmclaughlin22

Hi Illori, thanks for confirming that for me :) not to worry, maybe someone will have an idea.

margarett

I also don't know any MOD for that (it's the first time I've seen such request)

It should be doable with some custom coding. Not exactly complicated but also not a direct task...

Everything should be handled in Load.php, function loadUserSettings()
You need to check, upon user login, if they are "Club" members. If they are, load the user's custom profile fields and compare them all with (at least) not empty.
If check is OK, proceed
If is not OK, redirect them to the profile page

This will add a new query in all page loads for "Club" members, shouldn't be a major problem ;)

The task, in itself, is not *very* complicated... If the values can be hardcoded (group ID, custom field names, etc) then it's easier. But to build a full-featured MOD for this (with all the selections, verifications and whatnot) should be a royal PITA :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

Thanks margarett! I'll look into that :) I have done a lot of coding in the past but never any php. Can you point me in the direction of a good primer article for making mods in SMF?


margarett

I don't know if there is one. I learned by looking at other MODs. There is the SDK package but that's it...
http://www.simplemachines.org/community/index.php?topic=20319.0
http://www.simplemachines.org/community/index.php?topic=299669.0

I would suggest you to really hardcode the stuff. When you get it working you can then look at how to pack a MOD, then create configuration areas in administration, etc...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

dsmclaughlin22

Cool, thanks again, I'll let you know how I get on :)

~Drew

dsmclaughlin22

#7
Hi Again,

I've been looking into this problem and I need a little bit more help, first I will clarify the scope of the problem. When a user signs up they will see the following fields:



Then once they have paid their membership fees I would like to force them to fill in the following extra fields:



And by force, it could simply be that they still have access to the forum but they only to specific boards until they fill in the extra fields in the second image.

So... I've been looking at Load.php as suggested, but I've never worked with php before so it's a little bit difficult to get going. I found the loadUserSettings() and within there I /think/ I found the part I need to edit, or at least a relevant part below:

$user_info += array(
'id' => $id_member,
'username' => $username,
'name' => isset($user_settings['real_name']) ? $user_settings['real_name'] : '',
'email' => isset($user_settings['email_address']) ? $user_settings['email_address'] : '',
'passwd' => isset($user_settings['passwd']) ? $user_settings['passwd'] : '',
'language' => empty($user_settings['lngfile']) || empty($modSettings['userLanguage']) ? $language : $user_settings['lngfile'],
'is_guest' => $id_member == 0,
'is_admin' => in_array(1, $user_info['groups']),
'theme' => empty($user_settings['id_theme']) ? 0 : $user_settings['id_theme'],
'last_login' => empty($user_settings['last_login']) ? 0 : $user_settings['last_login'],
'ip' => $_SERVER['REMOTE_ADDR'],
'ip2' => $_SERVER['BAN_CHECK_IP'],
'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'],
'time_format' => empty($user_settings['time_format']) ? $modSettings['time_format'] : $user_settings['time_format'],
'time_offset' => empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'],
'avatar' => array(
'url' => isset($user_settings['avatar']) ? $user_settings['avatar'] : '',
'filename' => empty($user_settings['filename']) ? '' : $user_settings['filename'],
'custom_dir' => !empty($user_settings['attachment_type']) && $user_settings['attachment_type'] == 1,
'id_attach' => isset($user_settings['id_attach']) ? $user_settings['id_attach'] : 0
),
'smiley_set' => isset($user_settings['smiley_set']) ? $user_settings['smiley_set'] : '',
'messages' => empty($user_settings['instant_messages']) ? 0 : $user_settings['instant_messages'],
'unread_messages' => empty($user_settings['unread_messages']) ? 0 : $user_settings['unread_messages'],
'total_time_logged_in' => empty($user_settings['total_time_logged_in']) ? 0 : $user_settings['total_time_logged_in'],
'buddies' => !empty($modSettings['enable_buddylist']) && !empty($user_settings['buddy_list']) ? explode(',', $user_settings['buddy_list']) : array(),
'ignoreboards' => !empty($user_settings['ignore_boards']) && !empty($modSettings['allow_ignore_boards']) ? explode(',', $user_settings['ignore_boards']) : array(),
'ignoreusers' => !empty($user_settings['pm_ignore_list']) ? explode(',', $user_settings['pm_ignore_list']) : array(),
'warning' => isset($user_settings['warning']) ? $user_settings['warning'] : 0,
'permissions' => array(),
);


What I'd really like to know is:

1) Where I can check the values in my custom fields (the ones highlighted in the second image).
2) How can I then set the permissions for that user so that they only have limited access to the forum.
3) Is there a way to attach a debugger to make coding easier?

Thanks again! :)

dsmclaughlin22

Hi Folks,

I'm pretty stuck with this, can anyone out there help?

Thanks,

~Drew

margarett

The coding should be different, methinks.

I am thinking, eg, the way that SMF 2.1 redirects users without 2FA configured to that profile section

// Are we forcing 2FA?
elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] == 2 && $id_member && empty($user_settings['tfa_secret']))
{
$area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : '';
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';

if (!in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup'))
redirectexit('action=profile;area=tfasetup;forced');
}

Here (in that "else") I would add a new query to fetch the custom profile fields from that $id_member (because they aren't yet available at this point), check them for existent and filled and finally, if anything fails, redirect it to the profile page. When this works, we should add a message so that the user knows why he was redirected there :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kindred

(side note, please use code BBC for code... not teletype)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: