| @@ -39,10 +39,11 @@ | ||
| 39 | 39 | * @param int|string $user_id Numeric WordPress User ID. |
| 40 | 40 | * @param int|string $blog_id Numeric WordPress Blog ID. |
| 41 | 41 | * @param bool $s2says Optional. Defaults to false. If true, it's definitely OK to process this deletion? |
| 42 | 42 | * The ``$s2says`` flag can be used when/if the routine is called directly for whatever reason. |
| 43 | + * @param array|null $eot_access_before Optional access snapshot when removal has already cleared site roles. | |
| 43 | 44 | */ |
| 44 | - public static function handle_ms_user_deletions($user_id = 0, $blog_id = 0, $s2says = FALSE) | |
| 45 | + public static function handle_ms_user_deletions($user_id = 0, $blog_id = 0, $s2says = FALSE, $eot_access_before = NULL) | |
| 45 | 46 | { |
| 46 | 47 | static $processed = array(); // No duplicate processing. |
| 47 | 48 | global $pagenow; // Need this to detect the current admin page. |
| 48 | 49 | |
| @@ -57,9 +58,9 @@ | ||
| 57 | 58 | foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 58 | 59 | do_action('ws_plugin__s2member_during_handle_ms_user_deletions_before', get_defined_vars()); |
| 59 | 60 | unset($__refs, $__v); |
| 60 | 61 | |
| 61 | - c_ws_plugin__s2member_user_deletions::handle_user_deletions($user_id); | |
| 62 | + c_ws_plugin__s2member_user_deletions::handle_user_deletions($user_id, $eot_access_before); | |
| 62 | 63 | |
| 63 | 64 | foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 64 | 65 | do_action('ws_plugin__s2member_during_handle_ms_user_deletions_after', get_defined_vars()); |
| 65 | 66 | unset($__refs, $__v); |
| @@ -78,10 +79,11 @@ | ||
| 78 | 79 | * @attaches-to ``add_action('delete_user');`` |
| 79 | 80 | * @attaches-to ``add_action('wpmu_delete_user');`` |
| 80 | 81 | * |
| 81 | 82 | * @param int|string $user_id Numeric WordPress User ID. |
| 83 | + * @param array|null $eot_access_before Optional access snapshot captured before site membership removal. | |
| 82 | 84 | */ |
| 83 | - public static function handle_user_deletions($user_id = 0) | |
| 85 | + public static function handle_user_deletions($user_id = 0, $eot_access_before = NULL) | |
| 84 | 86 | { |
| 85 | 87 | static $processed = array(); // No duplicate processing. |
| 86 | 88 | |
| 87 | 89 | foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| @@ -93,8 +95,13 @@ | ||
| 93 | 95 | $eot_del_type = // Configure EOT/DEL type (possibly through this global variable). |
| 94 | 96 | (!empty($GLOBALS['ws_plugin__s2member_eot_del_type'])) ? // Is the global available for use? |
| 95 | 97 | $GLOBALS['ws_plugin__s2member_eot_del_type'] : 'user-removal-deletion'; // Else use default. |
| 96 | 98 | |
| 99 | + //261007.2015 Direct multisite removal can run after site roles are gone; use its captured access when supplied. | |
| 100 | + if(!is_array($eot_access_before)) | |
| 101 | + $eot_access_before = c_ws_plugin__s2member_eot::access_snapshot(new WP_User($user_id)); | |
| 102 | + $eot_notification_context = c_ws_plugin__s2member_eot::access_context($eot_access_before); | |
| 103 | + | |
| 97 | 104 | $custom = get_user_option('s2member_custom', $user_id); |
| 98 | 105 | $subscr_id = get_user_option('s2member_subscr_id', $user_id); |
| 99 | 106 | $subscr_baid = get_user_option('s2member_subscr_baid', $user_id); |
| 100 | 107 | $subscr_cid = get_user_option('s2member_subscr_cid', $user_id); |
| @@ -144,9 +151,9 @@ | ||
| 144 | 151 | if(is_object($user = new WP_User ($user_id)) && $user->ID && $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls']) |
| 145 | 152 | { |
| 146 | 153 | foreach(preg_split("/[\r\n\t]+/", $GLOBALS['WS_PLUGIN__']['s2member']['o']['eot_del_notification_urls']) as $url) // Handle EOT Notifications on user deletion. |
| 147 | 154 | |
| 148 | - if(($url = c_ws_plugin__s2member_utils_strings::fill_cvs($url, $custom, true)) && ($url = preg_replace('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($eot_del_type)), $url)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_id)), $url))) | |
| 155 | + if(($url = c_ws_plugin__s2member_utils_strings::fill_cvs(c_ws_plugin__s2member_eot::notification_fill($url, $eot_notification_context, TRUE), $custom, true)) && ($url = preg_replace('/%%eot_del_type%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($eot_del_type)), $url)) && ($url = preg_replace('/%%subscr_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_id)), $url))) | |
| 149 | 156 | if(($url = preg_replace('/%%subscr_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_baid)), $url)) && ($url = preg_replace('/%%subscr_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($subscr_cid)), $url))) |
| 150 | 157 | if(($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->first_name)), $url)) && ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->last_name)), $url))) |
| 151 | 158 | if(($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(trim($user->first_name.' '.$user->last_name))), $url))) |
| 152 | 159 | if(($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user->user_email)), $url))) |
| @@ -181,8 +188,9 @@ | ||
| 181 | 188 | $msg .= 'user_email: %%user_email%%'."\n"; |
| 182 | 189 | $msg .= 'user_login: %%user_login%%'."\n"; |
| 183 | 190 | $msg .= 'user_ip: %%user_ip%%'."\n"; |
| 184 | 191 | $msg .= 'user_id: %%user_id%%'."\n"; |
| 192 | + $msg .= c_ws_plugin__s2member_eot::notification_email_fields($eot_notification_context); | |
| 185 | 193 | |
| 186 | 194 | if(is_array($fields) && !empty($fields)) |
| 187 | 195 | foreach($fields as $var => $val) |
| 188 | 196 | $msg .= $var.': %%'.$var.'%%'."\n"; |