[wp-trac] [WordPress Trac] #51379: Add filter to function email_exists()

WordPress Trac noreply at wordpress.org
Thu Sep 24 08:18:47 UTC 2020


#51379: Add filter to function email_exists()
------------------------------------+------------------------------
 Reporter:  apermo                  |       Owner:  (none)
     Type:  feature request         |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Users                   |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+------------------------------

Comment (by apermo):

 Replying to [comment:4 swissspidy]:
 > Previously / Duplicate: #35509

 Basically I have the same use-case as mentioned in the ticket by
 @mikelopez.

 The only way I can currently do this is by using the filter
 `pre_user_email` and replacing the given e-mail address with one of a
 dummy account where I know that this will never be changed, so that the
 function `email_exists` will answer with `false`.

 I would actually prefer a completely different system similar to what is
 available with the login authorization.

 So some way to fire a custom error within `wp_insert_user()` would even be
 better. For examlple like this.

 {{{#!php
 <?php
         /**
          * Checks the given userdata and allows to inject a custom error
 during registration.
          *
          * This filter is called before the user is created or updated.
          *
          * @since TBD
          *
          * @param false|WP_Error
          * @param string $userdata Array with Userdata.
          */
         $custom_checks = apply_filters( 'wp_insert_user_custom_checks',
 false, $userdata );
         if ( $custom_checks instanceof WP_Error ) {
                 return $custom_checks;
         }
 }}}

 Added just before `$pre_user_login = apply_filters( 'pre_user_login',
 $sanitized_user_login );`

 That would likely be a new ticket, but would be a even more convenient way
 to solve my problem, as I would be able to throw a custom message.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51379#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list