WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I create a role and set capabilities for a group of user.

$userdata = array(
$uid = wp_insert_user($userdata);
    $blogger = new WP_User($uid);
    //add role
    $capabilities =  array(
        'read' => true,
        'publish_posts' => true,
        'edit_published_posts' => true,
        'delete_published_posts' => true,
        'edit_posts' => true,
        'delete_posts' => true
    add_role('blogger_simple', 'blogger_simple', $capabilities);
    $blogger -> set_role('blogger_simple');

Now, the user create successfully. I logged in to the system, and create one post , just one post.

Then I click the menu Post --> All Posts and found three columns there Mine(number) All(number) Published(number).

I click All(2), find I can see others posts?
I click Published(2), still 2 posts one is mine the other is by admin What's more, I search post, got the same results.

That's not I want, I just want to get my posts not by admin and all other user's post. How do I get just my posts when I click All/Published link below All posts menu, and also the search box.

share|improve this question
up vote 3 down vote accepted

You will need to filter that list.

function alter_views_wpse_103613($views) {
  $role = 'blogger_simple';
  if (current_user_can($role)) {
    $views = array('mine'=>$views['mine']);
  return $views;
add_filter( 'views_edit-post', 'alter_views_wpse_103613' );

That filter list is part of the WP_List_Table class if you want to investigate more. Look for the views method.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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