Support » Plugin: User Role Editor » Assigning new role as primary role, not secondary

  • Hello, I’m using a LMS plugin called LearnDash that changes a user’s role upon completion of a course,

    I’ve noticed that the new role is added to the user’s profile as a secondary role, not a primary. That is, the user’s primary role remains the same as when he or she registered for the site, but the new roles get added as secondary and tertiary roles.

    Ideally, I would like my users to have just one role at a time. That means their original role (when they signed up) is replaced with the new role they earned by completing a course.

    How can this be set up? I’m using the free version, but would be happy to upgrade to the paid version.

    Thanks.

    https://wordpress.org/plugins/user-role-editor/

Viewing 1 replies (of 1 total)
  • Plugin Author Vladimir Garagulia

    (@shinephp)

    I suppose that question is more related to the LearnDash plugin developer. It seems that he uses
    $user->add_role();
    method to extend user permissions not just replace the existing one, with
    $user->set_role();

    since version 4.3. add_role() method fires ‘add_role’ action:

    * @param int    $user_id The user ID.
     * @param string $role    The new role.
    do_action( 'add_user_role', $this->ID, $role );

    So it’s possible to catch LMS role addition and remove older role to make new one the primary role.

Viewing 1 replies (of 1 total)
  • The topic ‘Assigning new role as primary role, not secondary’ is closed to new replies.