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?
- Child theme – Overriding ‘require_once’ in functions.php
- Sort posts by Date (DESC) and by Title (ASC)
- Remove a menu item created by a plugin
- Using wp_get_nav_menu_items() to list children of children pages
- Custom menus displaying all pages instead of set pages
- Show Video in Excerpt
- How Can I Access a PHP Variable in Another PHP Function
- How to fix a theme with page.php Default Template that accidentally deleted?
- Override parent theme function that is not hooked or in the functions.php file
- Theme Demo in live Site
- function to include is_home, is_archive, is_category, is_author etc in one function?
- Change a sidebar name?
- Removing title from page
- get_the_excerpt() not returning anything when post has no excerpt
- Why isn’t is_page_template() adding a body class?
- Query children and parent title
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Still relevant method of embedding images in WP Theme in 2018
- Pass Shortcode Attribute to footer Script
- How to use Internationalized human_time_diff() function in Chinese?
- post to subcategory and parent in wp_insert_post
- Variable if post is sticky in functions.php
- Create a new query in function.php to filter blog posts
- Use third party Library in wordpress
- Creating new blog on multisite programatically without hacks?
- Limit number of users a role can create
- How to get correct URLs in network wide menu (Multisite)?
- WordPress Custom wp mail template return full template
- BuddyPress Edit activity function good practice
- wp_login_form display no styled form
- i recently bought a theme and when i try to activate it says (It appears wp_remote_get() function is disabled in your server. )
- Allowing a CPT post to be edited by a single user role