Skip to content

Instantly share code, notes, and snippets.

@afragen
Last active January 11, 2016 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afragen/5624319 to your computer and use it in GitHub Desktop.
Save afragen/5624319 to your computer and use it in GitHub Desktop.
Uses the hook new_user_approve_user_denied in the New User Approve WP plugin to delete denied users.
<?php
/*
Plugin Name: New User Approve - Delete Deny
GitHub Plugin URI: https://gist.github.com/afragen/5624319
Description: This plugin hooks into 'new_user_approve_user_denied' to delete the denied new user.
Requires at least: 3.1
Tested up to: 3.6.1
Version: 1.0.1
Author: Andy Fragen
Author URI: http://thefragens.com/blog/
License: GNU General Public License v2
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
add_action( 'admin_notices', 'nuadd_fail_msg' );
function nuadd_fail_msg() {
if ( !class_exists( 'pw_new_user_approve' ) ) {
if ( current_user_can( 'activate_plugins' ) && is_admin() ) {
$url = 'http://wordpress.org/plugins/new-user-approve/';
$title = __( 'New User Approve' );
echo '<div class="error"><p>'.sprintf( __( 'To begin using New User Approve - Delete Deny, please install the latest version of <a href="%s" class="thickbox" title="%s">New User Approve</a>.' ),$url, $title ).'</p></div>';
}
}
}
add_action( 'new_user_approve_user_denied', 'nuadd_delete_user' );
function nuadd_delete_user ( $user ) {
global $wpdb;
require_once( ABSPATH . '/wp-admin/includes/user.php');
wp_delete_user( $user->ID );
}
add_filter( 'new_user_approve_bypass_password_reset', '__return_false' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment