/** * Attaches actions/filters explicitly to users.php * * Callback for "load-users.php" hook * * @since 6.0 * @access public */ function load_users_page() { add_filter('user_row_actions', array(&$this, 'user_row_actions'), 10, 2); add_action('admin_notices', array(&$this, 'admin_notices')); add_action('delete_user', array(&$this, 'deny_user')); // Is there an action? if (isset($_GET['action'])) { // Is it a sanctioned action? if (in_array($_GET['action'], array('approve', 'resendactivation'))) { // Is there a user ID? $user = isset($_GET['user']) ? $_GET['user'] : ''; // No user ID? if (!$user || !current_user_can('edit_user', $user)) { wp_die(__('You can’t edit that user.', 'theme-my-login')); } // Where did we come from? $redirect_to = isset($_REQUEST['wp_http_referer']) ? remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_REQUEST['wp_http_referer'])) : 'users.php'; // Are we approving? if ('approve' == $_GET['action']) { check_admin_referer('approve-user'); if (!Theme_My_Login_User_Moderation_Admin::approve_user($user)) { wp_die(__('You can’t edit that user.', 'theme-my-login')); } $redirect_to = add_query_arg('update', 'approve', $redirect_to); } elseif ('resendactivation' == $_GET['action']) { check_admin_referer('resend-activation'); if (!Theme_My_Login_User_Moderation::new_user_activation_notification($user)) { wp_die(__('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login')); } $redirect_to = add_query_arg('update', 'sendactivation', $redirect_to); } wp_redirect($redirect_to); exit; } } }
*/ public function deny_user($user_id) { global $current_site; $user_id = (int) $user_id; $user = new WP_User($user_id); if (!in_array('pending', (array) $user->roles)) { return; } do_action('deny_user', $user->ID); if (!apply_filters('send_new_user_denial_notification', true)) { return; } if (is_multisite()) { $blogname = $current_site->site_name; } else { // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); } $message = sprintf(__('You have been denied access to %s', 'theme-my-login'), $blogname); $title = sprintf(__('[%s] Registration Denied', 'theme-my-login'), $blogname); $title = apply_filters('user_denial_notification_title', $title, $user_id); $message = apply_filters('user_denial_notification_message', $message, $user_id); if ($message && !wp_mail($user->user_email, $title, $message)) { die('<p>' . __('The e-mail could not be sent.', 'theme-my-login') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...', 'theme-my-login') . '</p>'); } } } Theme_My_Login_User_Moderation_Admin::get_object(); }