1

Using wpjobmanager plugin for my site gojobr.com.au :

I've encountered a problem: to combat spam users that keep posting the same spammy jobs (they are doing so manually so no a captcha won't solve the issue), I wanted to create an easy way to delete a user from the job_listings admin page ( wp-admin/edit.php?post_type=job_listing ).

I entered the following code and the column is appearing correctly on the job_listings page, however the nonce generated is different (and not working) to the wp-core users list admin page's user-delete link (which uses the exact same code as below). (located at wp-admin/includes/class-wp-users-list-table.php line 372):

// Populate content for this custom column add_action( 'manage_job_listing_posts_custom_column', 'gjcontent_job_listing_posts_custom_column', 99);

function gjcontent_job_listing_posts_custom_column($column) { /* @var $post WP_Post */ global $post;

switch ($column) {

    case 'user_info' :
        if ( empty( $post->post_author) ) {
           echo ' ';
        } else {
            $del_url = 'users.php?action=delete&user=' . $post->post_author;
            echo '<a href="' . wp_nonce_url($del_url) . '" title="Delete user">Delete</a>'; //nonce not working :-(
        }

    break;

}

}

1 Answer 1

3

You're not using nonces right - you need to match the nonce action & name that WordPress checks in core for deleting a user. Taken from the source of WP_Users_List_Table:

wp_nonce_url( "users.php?action=delete&amp;user={$post->post_author}", 'bulk-users' )
1
  • 1
    Awesome thank you, that worked! Eish bit of a schoolboy error from me not to notice it in the wp core file wiht the 'bulk-users' ... thanks again!
    – gvanto
    Commented Oct 9, 2015 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.