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
- Encrypt User last name in wordpress for security reasons
- How to: Easily Move a WordPress Install from Development to Production?
- What does this PHP function code mean? [closed]
- Is there a flowchart for WordPress loading sequence?
- How to change the default registration email ? (plugin and/or non-plugin)
- Essential technical features for high-end WordPress web hosting? [closed]
- How to remove admin menu pages inserted by plugins?
- How to put logs in WordPress
- How to get the Date Format and Time Format settings for use in my template?
- Add multiple custom fields to the general settings page
- Where are Additional CSS files stored
- How can I edit post data before it is saved?
- Best Practices for Regression Testing WordPress Websites?
- Remove wrapping div and ul from output of wp_nav_menu
- What Is The Use Of map_meta_cap Filter?
- How do you use a CPT as the default home page?
- get post author id outside loop
- Custom Walker: how to get ID in function start_lvl
- Creative uses of WordPress [closed]
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- How to *remove* a parent theme page template from a child theme?
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- Multiple Inputs in a Customizer Control
- New WP_Customize API – how does it work under the hood?
- Embedding a SOAP Client into a WordPress Plugin?
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Update widget form after drag-and-drop (WP save bug)
- Data sanitization: Best Practices with code examples
- How to benchmark a WordPress installation? [closed]
- don’t publish custom post type post if a meta data field isn’t valid
- Should I delete the default themes?
- Is there a way to set default custom fields when creating a post?
- Moving WP install from local to live, what about wp_posts GUID?
- Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
- Use wp init hook to call other hooks?
- Running Gutenberg React in Development Mode
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- Is there a blank theme framework compatible with WP 3.0? [closed]
- Plugin SVN & update API – how are plugins identified?
- Users with custom roles not showing in post author select box
- How to use more than 256MB of memory in the admin?
- How do register_sidebar() and get_sidebar() work together?
- How do you get formatted content of a post using the WordPress API?