Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Map Users to User Group
Avatar
TIGS ICT
Member
Free Members
sp_UserOfflineSmall Offline
Aug 2, 2012 - 9:49 pm

Hi

We are currently trying to map our users to certain groups in Simple:Press.

There are currently users of the blog but not members of the forums. We are using the "Members" plugin that enables us to have separate roles (supplementing the regular Subscriber, Editor etc roles with Student, Parent and Teacher). This part appears to be working perfectly. All the users (about 850) are either Administrators, Students, Teachers or Parents of the blog.

I now wish to map these blog users to our forum. Unfortunately when I try to run the "Map Users" tool it is not picking up anybody.

Now if a user logs in to the forum they are then put in the correct group - I just can't map them in those groups initially before they log in. I need to do this because I wish to split a few of the students in to class groups but cannot do this until they log in to the forum.

We are using Wordpress 3.4.1 and Simple:Press 5.1.2 under a multisite install. The forum is installed on a sub-blog (not the main one)

Please help!

Josh

 

hubusers0.jpgImage Enlargerfrownhubusers1.jpgImage Enlargerhubusers2a.jpgImage Enlarger

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 2, 2012 - 10:18 pm

wow. lots going on there. ;)

so it sounds like the plugin you are using for membership is not firing the standard wp hooks for new user creation on multisite... so the forum does not know the user is created until the user's first visit... and we have backup logic in place to create the user on their first visit if we were never notified of their creation...

the only way we (SP) can know there is a new user is via hook... when wp create a new user, it fires a hook so plugins can act accordingly... it appears you members plugin is not firing this standard wp hook...

Can you go to the admin for this network site (not the main site) and create a test user from the wp add user interface? and see if it gets put in user group properly... guessing it will...

Avatar
TIGS ICT
Member
Free Members
sp_UserOfflineSmall Offline
Aug 2, 2012 - 11:56 pm

Haha yeah there is lots going on! It's a fairly complex system... I forgot to mention another plugin - Multisite User Managment. This is the plugin that adds the users to the forum blog.

What hook are you referring to? That plugin is using this code:

add_user_to_blog( $blog_id, $user_id, 'student' );

Is there other hooks that I should know about?

 

Edit: Yeah you were right :)  I added a new user manually to the site and it created them fine in the forum.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 3, 2012 - 12:56 am

that's not a hook... its a function call... and I dont think its where the member plugin is actually creating the user...

the multisite hooks for user creation that wp uses are:

wpmu_new_user wpmu_activate_user added_existing_user

or the standard wp hook for user creation is:

user_register

they are fired whether user registers or admin creates in admin panel...

If you know where its done in the plugin, you could just call our member create function (which is the callback function to the wp new user hooks):

function sp_create_member_data($userid)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 3, 2012 - 1:37 am

ya know, something just clicked... forgot you said you were using this multisite user management plugin... so wonder if thats where non standard things are happening... could the user be getting created on a different network site or the main site? and then the management plugin is just 'copying' the user to the network site with the forum on it?? and hence we never get notified...

if so, wonder if there is a hook in the function you mentioned, add_user_to_blog(), that could be used to catch this other type condition... will check tomorrow...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 3, 2012 - 8:46 pm

ya know, that generally wont work... in your case, you dont have simple press running on the main blog so it wouldnt even catch the hooks that are used by those routines...

Avatar
TIGS ICT
Member
Free Members
sp_UserOfflineSmall Offline
Aug 5, 2012 - 7:49 pm

Thanks for this. You've given me something to work on. I guess I'll try to run the sp_create_member_data function during the adding users to the forum blog. I'll let you know how I go.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 5, 2012 - 9:48 pm

that should do it... but if simple press is not running on that site, the function wont run... you might have to switch to the blog simple press is on, then call the function... but try it and see...

Avatar
TIGS ICT
Member
Free Members
sp_UserOfflineSmall Offline
Aug 5, 2012 - 10:19 pm

Success!

I got it working by calling sp_create_member_data when adding the users to the blog. The only problem I had on Simple Press's side was that the line (137 ap-api-users.php):

$sql = 'INSERT INTO '.SFMEMBERS."

was not finding my forum blog - it was going to the main blog (wp_sfmembers). Changing it to:

$sql = 'INSERT INTO '.$wpdb->prefix."sfmembers

fixed it (wp_679_sfmembers).

I'm not sure if that was something I could have on my plugin side or if S:P is at fault. Anyway, it works...

Thanks for your help.

Josh

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 5, 2012 - 10:48 pm

yeah, that's why I said you might have to switch to the blog simple press is on before calling the function... nice work!

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17368
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626