You need to add , 10, 3 after your closure to set the hook priority and (more importantly) the number of accepted arguments – otherwise $user_email and $errors will not be passed.
add_action( 'register_post', function ( $user_login, $user_email, $errors ) {
$userIsValid = ValidateUser::make($errors);
if(!$userIsValid) {
$errors->add( 'bad_email_domain', '<strong>ERROR</strong>: errors' );
}
}, 10, 3 );
Update: The register_post hook only fires inside register_new_user(), which is only used for user registration via the WordPress login page.
To handle errors within the admin (i.e. Users > Add New) use the user_profile_update_errors hook instead.
Related Posts:
- How to add a new product type on woocommerce product types? [closed]
- WordPress hook before inserting post into database
- Making Custom Fields Standard in the Admin UI
- Check for and enforce unique value in user-entered custom meta field in WP Admin
- Add custom html to last sub-menu item
- Why isn’t is_home() working correctly?
- Any Hook Called When Post Becomes Published?
- When using the block.getSaveElement hook can you output different markup based on whether or not you are in the edit view or the live page view?
- generate unique number when registering a user
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Adding extra info via GET while registeration in wordpress
- Print shortcode in custom action hook not where the shortcode is entered
- Many users with strange names register, but don’t leave comments. Should I be afraid?
- Disable email field on WooCommerce customer account details
- Schedule cron event from widget
- Customizing the default logout page of WordPress
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- Edit admin post page
- How to pass external variables to the wp_new_user_notification_email filter?
- Add Div to Comment Form
- Add custom user profile field to default WordPress MultiSite registration form
- What’s wrong with Customizing new user notification email by add_filter?
- Function to allow “Anyone can register”?
- I want to submit multiple users if checkbox is checked
- Viewing checkout page removes fees from mini cart
- user_profile_update_errors hook not executing
- How Can I Move Data From Form 1 To Form 2
- Unable to sanitize in customizer and escape in theme without removing ability for user to use “< br >” to insert a line break
- Auto login from custom registration form
- Diffrent User registration form for doctor and patient
- Add Field to WordPress Register Form
- Custom login and registration forms
- How to append custom text to the output of ‘categories widget’?
- How to load a mycred hook from a plugin?
- WooCommer Product Category Loop – How to change the display order of the rating and price?
- Create Unique ID for user
- Custom Register Link on Backend Form
- Customize Widget Navigation
- How to change the login page without a plugin and not only customizing logo and text around the form?
- How to make WordPress search page use a relative path
- How can Use custom input field in functions.php page?
- customer specific email attachment
- Check get_post value after wp-admin login
- How to append the excerpt to the content in the single post page?
- How to display all post from the same current usermeta
- Creating Action Hooks For Automatic File Inclusion
- Customizing the built-in Media Playlist
- Custom user fields validation on registration
- Changing starting number of User ID
- Custom options – register, defaults and delete empty fields (Settings API)
- Which hook should I use for this scenario regarding the registration process and account/profile update?
- add unique code required to register
- User registration add user ID?
- How to get value from wp_usermeta table in database?
- Particle.js not loading in WordPress Gutenberg
- Redirect all pages to the custom login page except for the registration page
- Multiple content areas per page
- Set “Display name publicly as” to be usernames by default
- A Simple CRM Plugin for WordPress? [closed]
- Custom php file in wordpress
- Prevent WordPress from loading comments
- Display tags with a twist
- How to add another page in appearance tab of admin panel?
- WordPress change author email notify message?
- Last post is not showing up
- how to flush custom author rewrite rule
- add JS to multiple plugin admin pages
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- Follow me for WordPress blogs (multi-authors)
- Pagination Issues using WP_Paginate Plugin
- custom theme ,add media not showing images in media library
- Get Image from Media Library with the Title
- wpdb custom tables without plugin
- Registration Hooks don’t appear to be working
- WordPress 3.0.1 on IIS 6 Web Server PermaLink Issues
- Change Notice of Password change email subject?
- Deleting my old WordPress site. – issues
- How to assign a custom post title to be the post ID?
- Creating custom page template
- Which delete query is better with prepare or delete
- How to add page content into another page
- Remove Sidebars from page
- Show products per page drop down
- When developing WordPress plugin, is it a good idea to create my class object by hooking to existing class constructor?
- Static Page, need Last and Next links at the bottom
- Client viewing before deployment
- Change meta-box title- “LearnDash Quiz Settings” to “Quiz Settings”
- How to use a custom playlist template:
- Run a welcome tour after multisite creation?
- Multisite – Getting Meta query to select from wp_2 tables
- How to compare number with id of post in certain category
- WordPress Inline Style missing
- Need to over ride a !important from the index file
- Creating a search with tag variable also added for more detailed results
- Template setting is not saving in wordpress
- Redirect back to origin page after using get_delete_post_link()
- Create a custom search for Estate Agency WordPress site
- WP is easy, The client has to learn it, So what do i offer? [closed]
- How to apply filters if editing specific template
- How to use standalone Gutenberg (block editor) instance on any my own admin page in WordPress