Title: registration_errors filter problem
Last modified: August 21, 2016

---

# registration_errors filter problem

 *  Resolved [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/)
 * I’ve isolated this to NUA. I have a function set to list errors in my registration
   if the registrant doesn’t include a first or last name. I have added the first
   and last name to the registration screen. My understanding is that if the registration_errors
   filter returns an error then no registration will occur. This is precisely what
   happens with NUA deactivated.
 * When NUA is activated and the registration_errors filter fires the user is still
   created. I believe this is a bug, as the purpose of the registration_errors filter
   is to not create a user if the filter denotes errors.
 * Please let me know if there is any other info I can provide.
 * [http://wordpress.org/extend/plugins/new-user-approve/](http://wordpress.org/extend/plugins/new-user-approve/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Thread Starter [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926078)
 * I think I found the issue but I don’t know how to fix it.
 * The new user is created in send_approval_email(). This function is called using
   the register_post action hook. Unfortunately, register_post fires before registration_errors
   so there is no way to validate data.
 *  Thread Starter [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926079)
 * OK, this was a stupid error on my part. Just so everyone else learns.
 * I call my validation from ‘register_post’ not ‘registration_errors’
 * Make sure the variables in your validation are in the correct order.
 * `function my_validation( $sanitized_user_login, $user_email, $errors ) {`
 *  [LAONE](https://wordpress.org/support/users/laone/)
 * (@laone)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926299)
 * Andy, I’ve spent all day with the exact same problem and have gotten to the point
   where it’s clear that that register_post fires before registration_errors has
   even been called ( so that there is always a user created without validation )
 * Thanks for posting how you fixed it, I just wish I could apply it, but it’s not
   really clear to me how you did. Have you got anymore hints for me? How did you
   call the validations in the end?
 * Thank you!
 *  Thread Starter [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926300)
 * LAONE, this was all in a plugin I wrote. You can review it all here, [https://github.com/afragen/drmc-medical-staff-governance](https://github.com/afragen/drmc-medical-staff-governance)
 * You should be able to find the relevant parts in /classes/class-public.php
 *  [LAONE](https://wordpress.org/support/users/laone/)
 * (@laone)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926301)
 * Great thanks! Having a look!
 *  [LAONE](https://wordpress.org/support/users/laone/)
 * (@laone)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926302)
 * Thanks so much, I’ve managed to get to working looking at your code. Just for
   anyone who might run into a similar problem.
 * Change your registration_errors filter from something like this:
 *     ```
       add_filter( 'registration_errors', array( $this, 'la_registration_errors'), 9, 3);
       ```
   
 * to:
 *     ```
       add_filter( 'register_post', array( $this, 'la_registration_errors'), 9, 3);
       ```
   
 * and use the function like this:
 *     ```
       function la_registration_errors( $sanitized_user_login, $user_email, $errors ) {
         ...
         return $errors;
       }
       ```
   
 * The register_post hook now kicks in early enough for new-user-approve to check
   for $errors
 * Yay thanks Andy, saved my day!
    LAONE
 *  Thread Starter [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926303)
 * Glad you got this all worked out.
 *  Thread Starter [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * (@afragen)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926304)
 * For whomever wanders across this later. The above change to the `add_filter( '
   register_post'…)` is because I’m using it inside a class and LAONE isn’t.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘registration_errors filter problem’ is closed to new replies.

 * ![](https://ps.w.org/new-user-approve/assets/icon-128x128.gif?rev=2544141)
 * [New User Approve](https://wordpress.org/plugins/new-user-approve/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/new-user-approve/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/new-user-approve/)
 * [Active Topics](https://wordpress.org/support/plugin/new-user-approve/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/new-user-approve/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/new-user-approve/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Andy Fragen](https://wordpress.org/support/users/afragen/)
 * Last activity: [12 years, 5 months ago](https://wordpress.org/support/topic/registration_errors-filter-problem/#post-3926304)
 * Status: resolved