Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Delete Users Without Reassigning Posts
- Plugin URI: http://ru.forums.wordpress.org/topic/45228
- Description: Allows you to delete any user on large installs, where reassigning posts to another user might be problematic.
- Author: Sergey Biryukov
- Author URI: http://profiles.wordpress.org/sergeybiryukov/
- Version: 0.1
- */
- class Delete_Users_Without_Reassigning_Posts {
- function __construct() {
- add_action( 'pre_user_query', array( $this, 'disable_wp_dropdown_users' ) );
- add_action( 'admin_footer-users.php', array( $this, 'hide_reassignment_option' ) );
- }
- function disable_wp_dropdown_users( $user_query ) {
- if ( ! is_admin() || 'users' !== get_current_screen()->id ) {
- return;
- }
- if ( ! isset( $_GET['action'] ) || 'delete' !== $_GET['action'] ) {
- return;
- }
- $user_query->query_where .= ' AND 1=0';
- }
- function hide_reassignment_option() { ?>
- <script>
- jQuery(document).ready( function($) {
- $( '#delete_option1' ).closest( 'li' ).hide();
- });
- </script>
- <?php
- }
- }
- new Delete_Users_Without_Reassigning_Posts;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement