Support » Plugin: External Login » Reseting permission after someone login from External Login

Viewing 1 replies (of 1 total)
  • Thread Starter mativve



    After checking multiple solutions from FAQ section I think that I found solve my problem:

    This code based on email field from external database. I use this email to found user in WordPress database and get his roles.
    If you don’t have email field in your external database you can use other field with which you can find the user (e.g. username).
    More about searching user:

    If script found the user I get his current roles and return this variable. If roles is empty I set up default role which is ‘subscriber’.


    // Set permission from WordPress admin panel
    function set_wp_permission($roles, $username, $userData) {
        $user_email = $userData['raw_response']['email'];
        $user_wp_data = get_user_by('email', $user_email);
        $user_roles = $user_wp_data->roles;
        if( empty($user_roles) ){
            $user_roles = array('subscriber');
        return $user_roles;
    add_filter('exlog_hook_filter_assign_roles', 'set_wp_permission', 10, 3);

    I hope that helps 🙂

    • This reply was modified 1 year, 10 months ago by mativve.
Viewing 1 replies (of 1 total)
  • The topic ‘Reseting permission after someone login from External Login’ is closed to new replies.