You check the role not for the created user, only the currently logged in user. Try this way:
add_action( 'user_register', 'se333727_additional_roles' );
function se333727_additional_roles( $user_id )
{
$new_user = get_user_by( 'ID', $user_id );
if ( in_array( 'um_dueling-pianist', (array)$new_user->roles ) ) {
$new_user->add_role('pianist');
}
}
Related Posts:
- Custom registration URL lost when user makes signup mistake
- Allow user select role in wordpress default registration without plugin
- Restrict certain roles registrations by domain
- Add multiple custom fields to the general settings page
- Adding fields to the “Add New User” screen in the dashboard
- How to add first name & last name to default registration form?
- Apply custom role capabilities to administrator (without plugin)
- Roles & capabilities GUI that does not create separate table
- Create new user without password
- How to display error messages using WP_Error class?
- How to override WordPress registration and insert an auto-generated username?
- Restrict user registration to emails on a single domain
- How do I redirect upon login a specific user based on role?
- How to add another user to this remove_menu function?
- Add a new subscriber role using a function
- How to test for Super Admin
- Remove default user registration, login and subscriber profiles
- Custom roles can’t access to wp-admin
- WordPress registration and contact form 7 [closed]
- Custom function for specific user role
- Hide Author.php template from specific user role
- edit role display name and label name without plugins
- How to add custom fields to my custom registration form
- create shortcode to list users with specific meta key value
- Toggle User Roles with button
- How to change or add user role after getting post request data about pay? [closed]
- Display alert on successful user Sign Up
- Execute a ultimate member action when user role is updated
- Change label for registration Fields
- Allowing users to view private posts (pending approval)
- Multisite 404 on pages – rewrite error breaks database
- Registration Hooks don’t appear to be working
- Allow Contributor to edit their own posts after Adm aproval
- Trying to register script in footer
- How to add custom JavaScript in functions?
- How to set default post editor based on role?
- Is there a way to direct unregistered user to registration page when click a link?
- load CSS only for administrators on backend
- The Capability to choose post/page template
- How to add array [closed]
- call wp_insert_user in custom class doesnt work
- Get users with different roles and call function on each of them (user_meta)
- How to setup a popup registeration page in wordpress with function.php
- How can I show different content for different user-levels?
- Custom user role still showing up after deletion, ideas?
- How to load a css file depending on the current role
- Remove check boxes and its label from screen option for custom role
- Unable to login after registration
- Add Change role button for list of user in an event
- How to show only specific category post by user role without plugin and restrict all other cats
- Change user role based on total number of items ordered
- Remove all video attachment, both files and post/postmeta from database?
- delete_user_meta for user in spesific group
- Set display name from nickname with register process
- Change the second role depending on the first
- Changing the register url is not working
- Multisite Admin Roles
- Problem in outputting shortcode
- Problem in shortcode outputting content
- add_role menu pages are not visible
- Mail function not working with user accounts
- Register a widget area when a theme option has been saved?
- Welcome Mails based on user role
- Help finishing script to export WP user data when form submitted
- Get all users from role and add to dropdown (select) – wordpress, javascript
- Would it be possible to disable embeds for specific user roles? If so, how?
- How to make my logged-in user-role shortcode displaying name instead of slug?
- Custom User Role not working
- Text replace for the whole body tag
- Bizarre Child Menu Issue on WP Site
- How to display my comment count in the wordpress admin bar?
- Login cookies blocked after customizing hashing method
- Counting posts and trigger it [closed]
- Show ‘Add to Cart’ on Out of Stock products
- Combine page types and Custom Taxonomy in a functions.php command
- reWrite wp-content url to point on my cdn
- Order column custom date using pre_get_posts
- query_vars treat as single var from URL
- Running javascript without hooking wp_head
- Issue passing action class to nested function. Admin Columns
- Easily adding multiple existing users to a multisite site
- Assign user role by text field in WordPress (Woocommerce) [closed]
- Populate Product Regular Price with a calculated ACF Field Value
- Header menu aligned right on all pages except for single-post page [closed]
- Can’t load assets
- Display link to category over featured image
- Does hook have an effect on increasing the page load?
- WordPress Lite/Light
- Adding a schema code to one specific page using functions.php file
- Put images in the media from url functions
- Paragraph spaces in email template function
- Multiples functions on customize_register?
- How to add HTML into error message
- Hide ‘add to cart’ when certain value in dropdown is selected
- Can I call a functions.php file from a different URL?
- Why does modifying the “read more” link remove the link class?
- Javascript file loads only on homepage, not on other pages (404 not found error)
- Add a word after the post url if it is within a specific category
- Is it possible to load recaptcha script only in url with fragment identifier (#)?
- Ajax Form Issues using Lightsail (AWS)