Well, you’re not entirely correct. This code will run, when the action called basic
will be called using do_action('basic', ...)
. But… There is no such action in WP core, so your code won’t run at all, I’m afraid.
There is hook that might be helpful in your case. It’s called set_user_role
and it has 3 params ($user_id
, $role
, $old_roles
).
So your code should look more like this:
add_action( 'set_user_role', function( $user_id, $role, $old_roles )
{
if ( 'basic' == $role ) {
// Your code ...
}
}, 10, 3 );
Related Posts:
- Get author full name
- Receiving Stripe Webhooks on a wordpress website
- Integrating WordPress to my website, while keeping my own authentication system
- What would be a PHP command to erase all posts from category X from the last month?
- Add a wp editor to custom plugin and save data
- Walker class: Problems with understanding how walk() method can be called without error
- How to Use the Function is_user_logged_in To Display Different Menus?
- Change comments form title on a page by page basis
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Add value to usermeta without removing previous values?
- Authenticating to WordPress, using my own authentication two-factor system
- How to add default images into theme customizer image control?
- String replace WordPress Site Title
- WordPress Ajax Data problem
- Remove all nav menu classes ( but keep useful ones… )
- Add attribute / custom attribute to product in woocommerce
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- PHP can I add line numbers to file_get_contents()
- Displaying theme options in css
- Hide wordpress field if data is empty in post!
- database interactions using OOP
- Remove one value in dismissed_wp_pointers?
- Accessing data from a non-WP database/table within a page content
- Changing layout with wp_customise
- Extending the WP_Widget_Text class
- Selectbox in admin panel function linking to CSS
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Trying to build simple deposit code that hooks into woocommerce
- Add New User, extra fields which are required?
- user_profile_update_errors hook not executing
- Customizer: active_callback and sanitize_callback incompatibility?
- Saving and Restoring a Canvas on A Individual User Basis
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- custom url rewrite for wordpress
- Extend plugin Class through functions.php
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Menu jumping when calling it via PHP
- Output Video Download Link in template
- Modify custom field input data before creating a new post
- Output custom field value to post string
- “operation successful” message
- Change order of custom submenu link in WP Admin?
- Underscore – Self hosted fonts
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Function Reference Documenting Template Tags for use in Custom Theme Templates?
- Create page template via functions.php?
- How to create a field in customize and show that in header.php?
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- Delete or edit postmeta with specific meta_key?
- Update if post with specific title exists
- pass html code to worpdress
- How do I custom code the start page?
- Display movies that apear this day next
- Kohana Frontend, WordPress Backend
- is_user_logged_in returning nothing on custom page
- Customize field names in backend profile edit page through function.php [duplicate]
- how to add datas in taxonomy to post with wp_insert_post
- Change permalink structure specific category
- Array data not saving to specified sections. How to make seting independantly?
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Create Columns with Custom Walker and CSS Classes
- I need to display posts in subcategory beside posts in main category
- How can I check that the acf field value is not a duplicate when adding a post?
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- Integrate otp in my custom singup form
- How do I know if the user is a customer?
- How to block specific user id in custom login form?
- Inserting a class on before_widget if checkbox is checked
- Add a new view on the Woocommerce account page
- How do I add a predefined class to a custom html element?
- How to identify which php file a plugin is using on page load?
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- How to separate the taxonomies list from the form so that editing taxonmies is the same as pages and posts?
- Redirect user role to a specific page on login in a multisite network?
- How to add a full working piece of website already coded, to a large scale Website design project?
- Add custom attribute to product’s HTML to woocommerce cart page
- Create custom admin page with custom text fields
- Remove node from multisites?
- custom field – changing an element or background of id div – different versions not working
- Multisite – Display different header content based on which site is accessed
- How to get php file based on URL in WordPress
- How can I customize a WordPress theme before it’s downloaded?
- Replace Underscore (_) on Space ( )
- Why isn’t my custom Javascript showing up in my custom template?
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- PHP call div with function
- How can I show only if custom field has content [closed]
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Where can I find the code for the menu page meta boxes?
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- wp_head makes my custom page template not work in Customizer?
- HTML in PHP problem [closed]
- Woocommerce linking variations
- How to continuously developing a WP site that is already deployed in production without damaging it during development
- hello can you advise how to fix the error?
- Add multiple HTML attributes to an Elementor button