• Resolved mamad

    (@mrghasemi1047gmailcom)


    hi

    In the user role dropdown field, only the subscriber role can be selected, and other WordPress roles such as customer, editor, etc. cannot be selected. Is it possible to remove this restriction so that any role can be selected?

Viewing 5 replies - 1 through 5 (of 5 total)
  • missveronica

    (@missveronicatv)

    @mrghasemi1047gmailcom

    You can use field types “Roles (Dropdown)” and “Roles (Radio)” to set the user role in the registration form or change it in the profile form. But not all roles are available. Role fields may contain user roles created by Ultimate Member and predefined role Subscriber. User roles created by third-party plugins are excluded to avoid conflicts. Predefined roles with high access levels (such as Administrator or Editor) are excluded to avoid security vulnerability.

    https://docs.ultimatemember.com/article/1590-how-to-use-user-roles#fields

    You can extend the editable User roles list by this filter hook

    /**
    			 * UM hook
    			 *
    			 * @type filter
    			 * @title um_extend_editable_roles
    			 * @description Extend Editable User Roles
    			 * @input_vars
    			 * [{"var":"$editable_roles","type":"array","desc":"Editable Roles Keys"}]
    			 * @change_log
    			 * ["Since: 2.6.0"]
    			 * @usage add_filter( 'um_extend_editable_roles', 'function_name', 10, 1 );
    			 * @example
    			 * <?php
    			 * add_filter( 'um_extend_editable_roles', 'my_um_extend_editable_roles', 10, 1 );
    			 * function my_um_extend_editable_roles( $editable_roles ) {
    			 *     // your code here
    			 *     return $editable_roles;
    			 * }
    			 * ?>
    			 */
    missveronica

    (@missveronicatv)

    @mrghasemi1047gmailcom

    If you have created the UM Roles after the Form field was created
    you must remove the Roles field in the UM Forms Builder
    and create a new Roles dropdown field to get the new UM Roles selections
    added with the Roles dropdown in the Form selection list.

    Thread Starter mamad

    (@mrghasemi1047gmailcom)

    missveronica

    (@missveronicatv)

    @mrghasemi1047gmailcom

    Try this code snippet

    add_filter( 'um_extend_editable_roles', 'my_um_extend_editable_roles', 10, 1 );
    function my_um_extend_editable_roles( $editable_roles ) {
        $editable_roles = array_merge( $editable_roles, array( 'editor', 'customer', 'contributor' ));
        return $editable_roles;
    }

    Delete your current Roles dropdown in the UM Forms Builder.

    Recreate the Roles dropdown in the UM Forms Builder
    and you have now added the three additional Roles.

    Reload the frontend Registration page with three new Roles in the dropdown.

    Plugin Support Yurii

    (@yuriinalivaiko)

    Hi @mrghasemi1047gmailcom

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂

    Regards

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘dropdown role selector’ is closed to new replies.