Title: the4bee's Replies | WordPress.org

---

# the4bee

  [  ](https://wordpress.org/support/users/the4bee/)

 *   [Profile](https://wordpress.org/support/users/the4bee/)
 *   [Topics Started](https://wordpress.org/support/users/the4bee/topics/)
 *   [Replies Created](https://wordpress.org/support/users/the4bee/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/the4bee/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/the4bee/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/the4bee/engagements/)
 *   [Favorites](https://wordpress.org/support/users/the4bee/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin] Multiple user registration](https://wordpress.org/support/topic/multiple-user-registration-2/)
 *  Thread Starter [the4bee](https://wordpress.org/support/users/the4bee/)
 * (@the4bee)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/multiple-user-registration-2/#post-18285725)
 * It seems that the provided code allows access to any logged in user.
   The following
   is modified for access only by administrator or partner_manager roles:if ( ! 
   defined( ‘ABSPATH’ ) ) {exit;}
 * add_action( ‘init’, ‘custom_um_registration_access’ );
   function custom_um_registration_access(){//
   Check if Ultimate Member is available.if ( ! function_exists( ‘UM’ ) ) {return;}
 *     ```wp-block-code
       // If the user is logged in, verify they have an allowed role.
       if ( is_user_logged_in() ) {
           $current_user = wp_get_current_user();
           $allowed_roles = array( 'administrator', 'partner_manager' );
           if ( ! array_intersect( $allowed_roles, $current_user->roles ) ) {
               // User is logged in but not allowed; do not modify registration access.
               return;
           }
       }
   
       // Either not logged in, or logged in with allowed role.
       add_filter( 'um_registration_for_loggedin_users', '__return_true' );
       add_filter( 'um_field_value', 'custom_um_field_value_admin_registration', 10, 5 );
       ```
   
 * }
 * function custom_um_field_value_admin_registration( $value, $default, $key, $type,
   $data ) {
   // Ensure Ultimate Member’s fields are available.if ( function_exists(‘
   UM’ ) ) {$fields = UM()->fields();// Check that the fields object exists and 
   that we are in registration mode.if ( is_object( $fields ) && isset( $fields-
   >set_mode ) && ‘register’ === $fields->set_mode ) {$value = $default;}}return
   $value;}
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin] Multiple user registration](https://wordpress.org/support/topic/multiple-user-registration-2/)
 *  Thread Starter [the4bee](https://wordpress.org/support/users/the4bee/)
 * (@the4bee)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/multiple-user-registration-2/#post-18285009)
 * Magic! 
   I will go through it and see how I can adapt it to another user role.
   Then I will mark the thread solved.
 * Thank you very much!

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