If whatever is adding the second role is going through standard methods: WP_User::add_role()
then there’s the add_user_role
hook:
/**
* Do something whenever a new role is added to an existing user
*
* @param String $role
*
* @return void
*/
function wpse327081_add_uer_role( $role ) {
// Do Things
}
add_action( 'add_user_role', 'wpse327081_add_uer_role', 10 );
Related Posts:
- after login that will redirect user role into a page
- WordPress capabilities and restricted categories access
- register_activation_hook not updating
- Add_menu_page() error message -> “You do not have sufficient permissions to access this page”
- wp_get_current_user Not working
- How to hook update_post_meta and delete_post_meta?
- Are there any hooks that alter the 404 logic?
- WooCommerce: change display order of product short description and price [closed]
- Add_action to wp_head via functions.php
- Execute a function when admin changes the user role
- Is there a WordPress core & plugins update action hook?
- trigger save_post event programmatically
- Implementing advanced add_* function wrappers
- My add_action (wp_footer, ‘method’) is not calling?
- Hook into wp_head(); in a plugin
- is it possible to get the hook name in add_action?
- What hook is executed just after wp_query has been executed?
- How to properly test a method that is called by an action hook
- How can I do customizations on login, registration and password recovery forms?
- WordPress v5.0.3 Gutenberg & JS error “Uncaught SyntaxError: missing ) after argument list”
- Can’t get ID of post that relates to the comment
- Custom form action hook
- How to send an automated user ‘inactivity’ email?
- How do I successfully create a hook for an email override?
- WooCommerce – Overwrite action hook [closed]
- Admin Hook at the Login Page
- Cast string to number
- Custom action on login and “remember me”
- How to debug user_register hook
- Storing state between hook functions
- What’s the difference between “wp” and “wp_loaded”?
- Hook when new CPT published AND postmeta inserted
- Query categories that have a description
- How to use custom form on add_meta_boxes callback
- Is it possible to switch Gutenberg’s editor styles when document settings change?
- schedule event in class oriented plugin
- Action hook for custom tax edit
- wp cron job fires at every second or so, if callback is wrapped with DOING_CRON check it never fires at all
- How can I find the hook I need to rewrite a function?
- Show message in media-new.php
- Hooks are not being removed in child theme
- add_action second argument missing
- How to get user meta fields that have just been updated?
- admin_notices action doesn’t trigger within save_post action
- When a plugin gets updated from the repo, does the “activation” hook fire again?
- Insert HTML in post, below nav bar but above content?
- Convert Gravity Form Entry Date on Export
- Defining hooks within (php)classes?
- Divi hook not working [closed]
- Add WordPress hook outside of Plugin or Theme
- How to perform action when plugin/theme editor is used?
- Add PHP code to header section from plugin
- How to run hooks one by one manually?
- How to change a WordPress term’s slug before saving
- dynamic add_action according to child pages (for homepage control)
- What is the proper hook to use for recording a post view?
- How to load this code on function.php
- What hook should I use that will fire whenever I open a post for editing in the WP back-end?
- Woocommerce single_product_summary hook not working
- Where is publish_post hook fired?
- A good hook to check authorization and redirect?
- Is there a author_update action?
- Bloginfo hook – can it be more precise?
- Custom posts and get_post_meta in {$post_status}_{$post_type}
- Hooking custom PHP output into WP: how to do it, parse_request almost works but not quite
- How to get product information using hooks?
- Print on screen during shutdown hook – error during saving in theme-editor.php
- How to stop execution of a function via add_action hook?
- changing genesis_before_while in new theme framework
- Moving Javascript from footer to header
- Adding a new hidden field based on a condition in Ninja Forms
- Forcing WooCommerce customers to create account before checking out
- Store user ID on wp_term_taxonomy when new term inserted
- ‘user_register’ hook – need to distinguish if created from wp admin panel
- Make multiple URLs behave as home page
- remove_action not working for a function
- What hook should I use to add post meta data with on update?
- Transition_Post_Status hook not working properly
- Wodpress XML Import hooks
- profile_update hook does not fire from front-end
- wp_update_post not getting triggered by hook
- Problem with call_user_func_array front end
- How to I prevent WordPress from switching external HTTP links to HTTPS?
- Stylesheet is getting removed/deregistered automatically
- How to override get_avatar() function?
- add extra parameter in default hook in wordpress
- Change user role if it’s orders count more than
- Exclude WooCommerce terminations from YOAST
- add hook restricted only to either plugins or themes?
- How to hook watchdog script for existence of a WP page?
- Using actions, hooks and filters in a non-WordPress page
- addaction hook cause redirection problem
- Hook into create_category
- Trouble adding data to options table
- How to hook into publish_posttype?
- $GLOBALS & global doesn’t work [closed]
- How to use the password_reset hook to validate new password and display error
- Hooks not working on live server
- theme.json is altering Group block HTML
- Not able to set userId and email at wp_set_current_user in Worpdress