Fork me on GitHub
Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.
Critical: Update to 2.1.8, released 15 Jan.

automatic assigning roles

jeroengjeroeng New
edited March 2012 in Vanilla 2.0 Help
This discussion is related to the Vanilla jsConnect addon.


Is it possible when using jsconnect and php to assign users to a certain role? In the example the name, email etc. is passed. But there is no documentation about what else could be passed.




Best Answers

  • KezzBKezzB New
    Answer ✓

    I just spent the whole day trying to figure this out and finally got it going.

    As mentioned above, you need 2.1 branch.

    After that it's actually super easy once you find it.

    You just add to your config.php this setting:

    $Configuration['Garden']['SSO']['SynchRoles'] = TRUE;

    Then your array of roles will carry through perfectly.

    I'm using WP Vanilla Connect plugin on WordPress, so I just changed it from this:

        $user = array(
                'uniqueid'  => $current_user->ID,
                'name'      => $current_user->display_name,
                'email'     => $current_user->user_email

    To this:

         $user = array(
                'uniqueid'  => $current_user->ID,
                'name'      => $current_user->display_name,
                'email'     => $current_user->user_email,
                'roles'     => "Member,Moderator"

    Now it's working great.

    I'm also going to have it check on my user's levels on WP first, as I'm using the s2Member plugin, so then I can create a tiered access system in the forum.


  • KezzBKezzB New
    Answer ✓

    Thought I'd also share the code I used to synch my WP s2Member roles with my forum in case anyone else finds it useful:

    //get current user role
                $thisrole = "Level 4";
            } else if(current_user_can("access_s2member_level3")){
                $thisrole = "Level 3";
            } else if(current_user_can("access_s2member_level2")){
                $thisrole = "Level 2";
            } else if(current_user_can("access_s2member_level1")){
                $thisrole = "Level 1";
            } else if($current_user->role=="subscriber"){
                $thisrole = "Free Member";
            } else {
                $thisrole = "";
            // Map the current user values for jsConnect
            $user = array(
                'uniqueid'  => $current_user->ID,
                'name'      => $current_user->display_name,
                'email'     => $current_user->user_email,
                'roles'     => $thisrole


Sign In or Register to comment.