Resources

My Agape try

Your Agape try


Support Forum

Current User: Guest Login Register
Please consider registering

Search 
Search Forums:


 




Automatically assign user to new role?

UserPost

12:03 pm
May 4, 2010


jaime

New Member

posts 1

1

Hi Kevin,

First, thank you for this amazing plugin! I was astonished to learn a WordPress doesn't have these types of features built in.  Now on to my question…

I have set up a daycare school WordPress + Role Scoper site that has 2 private (registered users only) sections: 1) Parent Section, 2) Teacher Section.  I am utilizing 2 user groups called: 1) Parent, 2) Teacher.  "Parent" users only have access to the Parent Section, while "Teacher" users have access to both sections.

By default, all new registered users are assigned to the "Parent" user group, and thus, are only given access to the Parent Section.  The problem I have is when  teacher registers.  Right now, the only way to assign someone to the "Teacher" user group is to manually log into WordPress and put them in that group.  What I would like to be able to do is set things up so that when a teacher registers, they can enter an invitation code and if it validates, have WordPress automatically assign them to the Teacher user group.  Is this possible?

FWIW, I realize the invitation code/validation is a separate part of the puzzle from Role Scoper. I guess I am trying to figure out what the code would like like to make a function call to WordPress/Role Scoper to change a user's assigned User Group.

Any pointers or guidance you might provide would be greatly appreciated!

8:26 pm
May 4, 2010


Kevin

Admin

posts 1385

2

jaime said:

I guess I am trying to figure out what the code would like like to make a function call to WordPress/Role Scoper to change a user's assigned User Group.


It sounds like this is all you need (modifying group name as needed):

global $current_user;
$group = ScoperAdminLib::get_group_by_name( 'Teachers' );
ScoperAdminLib::add_group_user( $group->ID, $current_user->ID );

Just make sure you don't have the 'assume no front-end admin' option enabled.



Reply to Topic: Automatically assign user to new role?

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 8 + 1        (Required)

Topic Reply:


 

About the Agapetry forum

Currently Online:

10 Guests

Maximum Online: 88

Forums:

Groups: 2

Forums: 7

Topics: 707

Posts: 3193

Members:

There are 642 members

There are 1 guests


Kevin has made 1385 posts

Top Posters:

metal450 - 98

YikYak - 58

Ragnar - 36

Daisy - 35

victar - 33

Administrator: Kevin | Moderators: Kevin