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
- Remove Actions/Filters added via Anonymous Functions
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- How to add classes to images based on their categories?
- Generating Responsive Background Image Sizes in PHP
- Session is not starting
- Hide WYSIWYG editor on certain templates
- Disable shortlinks like ?p=1234 to prevent scraping
- Redirect a list of URLs to another URL, using functions.php
- How to limit character length in BuddyPress function output [closed]
- Ordering posts by publish date not working?
- Is possible add icon in title posts only in specific tag?
- Wp_schedule_event functions.php
- Display tags that only appear in one category
- Space Not Being Generated in HTML Output?
- Auto Generated HTML source code formatting
- Do not show on homepage functions.php code needed
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- How to remove a specific word at the beginning of the content and add it to the end of the content
- Passing Jquery value to WordPress function
- How to pass variables from one function to another or combine functions
- How to create a shortcode out of a php function
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- Internet Explorer opens links to .msi files as text in a new tab
- I would like single.php to act just like index.php
- A better way to get stats
- Get URLs for AJAX Filter Checkboxes WordPress
- Show number of sold products but be first for less than 2
- Class::$template_dir_path=get_template_directory();
- admin-ajax.php & my wp-admin folder url showing in header
- Error function main() is a non-object to construct my Ajax.php
- Gravity Forms After Submission – GFFormsModel::update_lead_field_value?
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- Missing argument 2
- Different ads on every website on multisite environment
- How to get variable from other function inside class function using add_action for Ajax call