[wp-trac] [WordPress Trac] #35428: Allow the suppression of errors if user already exists

WordPress Trac noreply at wordpress.org
Tue Jan 19 22:33:27 UTC 2016


#35428: Allow the suppression of errors if user already exists
------------------------------------+------------------------------
 Reporter:  pbearne                 |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Login and Registration  |     Version:  trunk
 Severity:  normal                  |  Resolution:
 Keywords:  reporter-feedback       |     Focuses:  multisite
------------------------------------+------------------------------

Comment (by pbearne):

 Below is the code in S2 member that would be called for this filter

 from quick read it seems to add an existing User

 I hope this help understand why the filter is needed

 {{{#!php
 <?php
 /**
  * Intersects with ``wpmu_activate_signup()`` through s2Member's Multisite
 Networking patch.
  *
  * This function should return the same array that
 `wpmu_activate_signup()` returns; with the assumption that
 ``$user_already_exists``.
  *   Which is exactly where this function intersects inside the `/wp-
 includes/ms-functions.php`.
  *
  * This can ONLY be fired through `/wp-activate.php` on the front-side.
  *   Or through `/activate` via BuddyPress.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_filter('_wpmu_activate_existing_error_');``
  *
  * @param WP_Error $_error Expects a `WP_Error` object to be passed
 through by the Filter.
  * @param array    $vars Expects the defined variables from the scope of
 the calling Filter.
  *
  * @return WP_Error|array If unable to add an existing User, the original
 ``$_error`` obj is returned.
  *   Otherwise we return an array of User details for continued processing
 by the caller.
  */
 public static function ms_activate_existing_user($_error = NULL, $vars =
 array())
 {
         foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =&
 $$__v;
         do_action('ws_plugin__s2member_before_ms_activate_existing_user',
 get_defined_vars());
         unset($__refs, $__v); // Housekeeping.

         extract($vars); // Extract all variables from
 ``wpmu_activate_signup()`` function.

         $ci =
 $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' :
 'i';

         if(is_multisite()) // This event should ONLY be processed with
 Multisite Networking.
                 if(!is_admin() && ((preg_match('/\/wp-activate\.php/'.$ci,
 $_SERVER['REQUEST_URI'])) ||
 (c_ws_plugin__s2member_utils_conds::bp_is_installed() &&
 bp_is_activation_page())))
                 {
                         if(!empty($user_id) && !empty($user_login) &&
 !empty($user_email) && !empty($password) && !empty($meta) &&
 !empty($meta['add_to_blog']) && !empty($meta['new_role']))
                                 if(!empty($user_already_exists) &&
 c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login,
 $user_email, $meta['add_to_blog']))
                                 {
 add_user_to_blog($meta['add_to_blog'], $user_id, $meta['new_role']); //
 Add this User to the specified Blog.
                                         wp_update_user(wp_slash(array('ID'
 => $user_id, 'user_pass' => $password))); // Update Password so it's the
 same as in the following msg.
 wpmu_welcome_user_notification($user_id, $password, $meta); // Send
 welcome letter via email just like ``wpmu_activate_signup()`` does.

                                         do_action('wpmu_activate_user',
 $user_id, $password, $meta); // Process Hook that would have been fired
 inside ``wpmu_activate_signup()``.

                                         return
 apply_filters('ws_plugin__s2member_ms_activate_existing_user',
 array('user_id' => $user_id, 'password' => $password, 'meta' => $meta),
 get_defined_vars());
                                 }
                 }
         return
 apply_filters('ws_plugin__s2member_ms_activate_existing_user', $_error,
 get_defined_vars()); // Else, return the standardized error.
 }
 }}}

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


More information about the wp-trac mailing list