You can use in_array to check if the name of the role is either customer or shop_manager
add_action('register_form', 'myplugin_register_form');
function myplugin_register_form() {
global $wp_roles;
echo '<select name="role" class="input">';
foreach ($wp_roles->roles as $key => $value):
if ( in_array( $key, array('customer', 'shop_manager') ) )
echo '<option value="' . $key . '">' . $value['name'] . '</option>';
endforeach;
echo '</select>';
}
Related Posts:
- How do I programmatically set default role for new users?
- How to loop through each user id?
- Roles at registration (classipress)
- wordpress separate registration for different roles
- Auto Delete Users (auto_delete_users)
- Is there a way to set the user Role based on email domain
- User registration approval based on role selected
- New user created as Participant rather than Contributor [closed]
- How to give new users two specific user role options upon WordPress user registration
- How to create user specific pages (not user role!)?
- How to change a user’s role conditionally to expire after two weeks
- Menu page with list of users
- How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]
- Add a second role when registering programmatically
- What would cause wp_insert_user role to work sporadically?
- How to Enable registration email for a custom user role?
- Add role selector to custom registration page
- Multiple user role on registration
- add user role selection to registration form [duplicate]
- How to assign role to a custom registration form?
- User role can’t be set
- User has empty instead of custom role when logged in
- Check role of Username then echo something if administrator [closed]
- read_private_pages capability not working for new role
- Get and display a user’s profile info?
- How to get a users list by who created them?
- Plugin creation – how to add user rights?
- Paypal API and WordPress
- Force modified contributor role to be re-approved on edit?
- User register hook is not working in woocomerce register form
- Password minimum length in personal subscription [closed]
- Run a code only on theme activation only during first activation
- Updater user with multiple roles
- Custom user types getting html sanitized in posts
- User roles are changing automatically
- Add post with approval by the admin
- Is there a Capability that checks as true for non-logged in users?
- User restricted only show posts assigned to current user
- Stop contributors from editing standard posts but allow them to edit a custom post type
- How to hide a HTML element based on user role
- How to change a user role after registering in multisite?
- Give Editor Access to Custom Theme Options
- Authorize users for specific pages and/or categories
- Restrict custom post content to specific user
- Fatal error: Call to undefined function register_new_user()
- Custom Capabilities for CPT and Problem with current_user_can()
- List users of an array of roles
- How Can I Edit the Registration Code?
- Custom wordpress admin page/url “You do not have sufficient permissions to access this page.”
- Hiding custom theme functionality using capabilities
- user_can() not working for comment authors
- create new user role for reader
- How do you create two separate Register pages?
- Use PHP code to create custom user roles. Call it once?
- Which capabilities are available in Gravity Forms Salesforce plugin? [closed]
- How can I programattically hide all admin notices for everyone except admin users
- Woocommerce Wcvendors – duplicate emails when Vendor approved
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- custom plugin not visible to some user roles
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- How to write conditions based on user capabilities not on user role?
- Hide front-end from every logged out user and redirect them to the default login page
- Custom shortcode for displaying user based on a role parameter
- Add User Role: Pre-saved in User-Meta [SOLVED]
- How to exclude subscriber from the list in wordpress
- What Capability is required to let a role RUN code in Edit Theme?
- Hide Users by user role in Worpress
- Want to know parameters that can be passed to user_can() for access control by user capabilities
- Shortcode for Listing Users from Meta Value?
- Adding additional roles on registration
- WordPress add_rewrite_rule redirection match GET variable not passing through to custom template
- How do I create a new post upon registration with the users first and last name as title
- ‘upload_mimes’ filter seems to be restricting viewing/downloading as well
- Block user roles from accessing the WordPress dashboard
- Array to string conversion error in PHP 7.2 when returning user role as class
- Change user role of a particular user at specific time
- How to trigger an error: “You are not allowed to edit this post.”
- How to restrict an admin page, if the user is not superadmin?
- Allow user edit widgets
- Problems using ‘add_role’
- Custom Registration username_exists / email_exists
- Customising “user ids” and add to ‘user’ panel in the admin area
- allowing subscriber role to delete their own posts
- Create sub-administrator role that can do everything except use or see the code editor
- Make a single page in WordPress available only for Admin and Subscribers
- How to hide some users to unlogged users [closed]
- Noindex subscriber author page
- remove_cap nothing changes
- Can we hook the Customizer on a post or page on the front of the site?
- display user roles in comment form
- Custom User Registration script only allowing usernames with 16 characters
- get_post_meta with related user
- Let users edit their role from the frontend
- How to change a user’s role depending on date registered?
- Query for user roles
- Let editors view post in admin but not be able to perform a save/edit
- Restrict access to a post once it is tagged as a given status
- List of users with email and role
- Capabilities don’t add
- Migrating Roles from one environment to another