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:
- Why have on every line
- WordPress and event-driven programming – what is it about?
- Cleaning up WordPress to improve performance?
- Include a external PHP file into a WordPress Custom Template
- List of all theme customizer control types?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- Remove option to allow trackbacks/pingbacks from post page options
- How to remove hardcoded characters from playlists?
- Creating custom Woocommerce attribute taxonomies from a plugin
- Load post content into iframe
- wp_customize_image_control default value
- Search and Replace in database: How to replace data in SQL dump file on Windows?
- delete an array element when its date expires
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Is it recommended to pass some data to scripts in `wp_enqueue_scripts`?
- Random Default Avatar Function
- Change the site tagline (or similar) based on current page
- Customizer: Output default value in Customizer CSS
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Converting HTML Template to WordPress Theme
- Can I install/embed WordPress on a ‘single page’?
- How to check if a meta value has already been assigned to any user?
- How to pick the default selected value in wordpress dropdown?
- Customize position of social icons in upme plugin [closed]
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Media Upload , file name changed automatically
- Replace shortcode in substring
- Custom posts in different columns style
- need help with existing code showing subpages
- How do I add a custom css to all posts without affecting homepage css? [closed]
- how to show only specific category for a template
- Advanced Custom Fields not displaying
- How to get private property in parent class into extended class?
- Exclude posts with specific metadata from search?
- Add data-id attribute to child page links
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Warning: Illegal string offset on theme options page [closed]
- Display Youtube Time Automate from Key
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- Where is the PHP code generating an element?
- Basic wpdb update question
- Check class_exists before class definition / Doxygen problem
- Extract links from content
- Integrating Yii2 and WordPress
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- Custom Registration username_exists / email_exists
- After disabling WPML multi currency, the currency is still handled by the WPML
- How do i wrap woocomerce attribute in list?
- PHP Helper Class to create shortcodes
- Reusable code that I can store in the function.php and apply to other templates as need. Dry Code
- Is it possible to add a custom page to a free WordPress site? [closed]
- Is there a hack for using is_page() within the function.php file?
- save metabox with new values _wp_page_template
- How to Fix an Archive.php That Displays All Posts?
- pagination broken – clicking next displays “page not found”
- Site DOES NOT LOAD after 3.1 update
- Create condition for Author bio Social Links
- Customizer control save then return to default
- WP-Bakery – Add custom colors to buttons with template colors
- Woocommerce template file outputting tags
- Trying to update Woocommerce meta values
- update_user_meta as multiple value but with same meta key
- retrieve “Link Color” value
- If Statement is Ignored?
- Delete post meta by serialized meta value
- Dynamic Banner Text based on Subdomain
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Create Schema in WordPress with PHP
- Create form which redirects to site in network?
- Remove specific javascript when viewing page in Customizer?
- Search only for posts with specific metadata?
- How to associate dynamic PHP page for chosen WordPress tag?
- Only display notification on single post
- Is there a way to have chunks of a page’s content expire?
- Where can I find the declaration of `$_wp_theme_features`?
- Static home page ignored
- How do I routinely extract the thumbnail of the most recent post?
- Showing the project type in HREF
- Display tab title as ‘blog tagline | blog title’
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Showing custom field contents without listing description
- How to use PHP code with wordpress page
- Check if values exists DB
- if is_bbPress register jquery
- Auto create description in post
- Pagination on Custom Loop
- Widget header unique classes
- why is this content-template not showing any of my blog-entries?
- How to get the count for each taxonomy term
- error with WP custom form
- How can I clear the theme mod settings?
- MySQL Engine vs. Charset
- Save Option on Database
- Select area and checkbox data is not saving?
- In reading settings posts are set to “blog” and I have page-blog.php but no posts
- WP Custom tables query
- How to change product title color in shop page if product has specific product tag (Woocommerce)?