Yes, this is possible. WordPress defines a function named wp_new_user_notification
. You can override this function by creating your own version (also named wp_new_user_notification
) in your own theme or plugin.
You may wish to start by copying the contents of the existing core version into your own copy. You can now customize the logic for your own needs.
Since this function passes the $user_id
as the first argument, you can use get_userdata
to obtain more information about the user (for example that user’s roles) and then send different content depending on their role.
$user_data = get_userdata( $user_id );
if ( ! empty( $user_data->roles ) ) {
if ( in_array( 'role_a', $user_data->roles, true ) {
// custom content for role a
} elseif ( in_array( 'role_b', $user_data->roles, true ) {
// custom content for role b
}
}
Related Posts:
- How to bulk send emails
- WordPress plugin for mail subscriptions [closed]
- action-scheduler vs wp-background-processing
- Check if email address exists front end with AJAX in a plugin
- How to pass variables to a function argument using add_action [duplicate]
- SMTP Error: Could not authenticate [closed]
- I want to schedule email (date, time is in database->table) wp_schedule_event() not working
- Form tries to download a file on submit
- How to customize ‘recurrance’ of’ wp_schedule_event’?
- Send email notification when meet the condition
- WordPress isn’t sending welcome email with the password reset
- WordPress plugin from own server
- How to avoid plugin name conflicts from the upgrade notifier?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Customizing subject in comment notification e-mails
- Add content to /wp-admin/plugin-install.php admin screens
- Need a function for changing saved post_date or post_date_gmt to relative time in wordpress
- Activate Plugin which is in subfolder?
- Plugin child folder?
- Autoload via composer in plugin interference
- merging an array to an existing array using add_filter
- How do I store information in a dynamic block in WordPress?
- wp_mail attachment not working
- Is it possible to set up multistore in Woocommerce? [closed]
- Plugin exceeds memory limit
- Find the URL of the current plugin directory
- Plugin Paths Issue
- How to generate video out of images via WordPress plugin
- Woocommerce plugin for minimum order and add-to-card-step
- UnInstallation of a Plugin from a developers perspective – The correct and clean method
- Email Bounce Address
- How to slice an array using posts_per_page? [closed]
- Get plugin option in another PHP file
- woocommerce payment gateway callback not firing [closed]
- White page by using filter template_include
- How to export post 2 posts WordPress plugin data [closed]
- Customization API for plugin development
- User switching only with specific role and return
- Adding Font Awesome to WP Plugin
- Display custom content using page.php from theme
- Remove .htaccess portion upon plugin deactivation?
- Implementing an “Email this” button?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- First plugin, problem with get_pages
- How to check if an email was sent from or originated from a specific plugin?
- Collecting email addresses via a “beta” sign up form
- Translations for my plugin don’t show up
- Translation issue with global variables
- Function added to hook “new_to_publish” not executing – custom plugin
- How to access OOP plugin function inside themes or other plugin
- change or add css to theme from plugin
- Displaying data from another database
- Every time I de-activate a custom plugin, the site encounters a critical error
- Custom Fields for Page Edits
- Apply html elements in php statement
- How do I remove all traces of a plugin?
- Is it possible/advisable to set last stable version to previous version?
- How to make sure settings are not lost when plugin is updated?
- How Can i import plugin option?
- WordPress – send digital product with custom email
- How to override any plugin file in the child theme
- How can replace this url
- How to overwrite a plugin?
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- SimpleXML is not working with xml response from external api
- Custom Plugin Update
- How do I stop plugins and themes from getting updated in a new plugin?
- How come W3TC is allowed to host premium code in the WordPress repo?
- Multiple image selection custom widget
- Custom wp_list_tables redirect on specfic page
- Passing function into add_action always returns the first argument
- Hook to display element as product on category page
- Missing files in enqueue actions causes WordPress to reload
- I can’t use WP_Query
- Adding/ Removing actions for plugins
- Creating Nested custom fields
- plugin not hooking to my custom hook
- Populate select option with JSON file
- Enahanced search for edit.php and custom post type
- WP Plugin: Print javascript in header
- Adding list of Indexes in wordpress document
- API Functions to Register and Show WordPress List Tables
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- Ajax, jQuery and WordPress
- Add custom fields in the new and edit the site forms without touching the WP core
- Extend WordPress REST API with Scheme Pro Plugin
- How to submit the custom form data in database in WordPress without plugin?
- Unable to show 4 products in a row
- WordPress check box unchecked on null value ternary operator [plugin development]
- Embed php code in custom field of a plugin [closed]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- WP Elementor Pro causing crtical failure on website
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Wrong block appender button showing
- Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table
- plugin doesn’t retrieve data from database
- Display Any Field fromAdmin Panel in Frontend via Shortcode?