In my user registration, the user can them selves choose their role.
But I have not been able to hook this up with user registration.
I'm also not able to run my function from my plugin using add_action.
So what I do now, is to call my function on page load (Above the header - before <!DOCTYPE>).
Unfortunately the user have to reload the page to see the effect. I'm currently looking into how I can solve this problem, and change user role before anything else is loaded (that is role based).
Here is my function:
function changeUserRole()
{
global $current_user;
get_currentuserinfo();
$user_ID = $current_user->ID;
$user = new WP_User( $user_ID );
$roles = array(... list of roles...);
// Set new user role.
foreach($roles as $role => $name) {
if( $current_user->role == $name)
$user->set_role($role);
}
}