Skip to main content
added question mark to the final question - fixed formatting by indenting code - using gender-neutral "they" instead of "he"
Source Link

I have a membership website where my users can create their own page. I use below snippets in function.php to remove the options of published, trash etc. of other users and only show "mine".

/**

  • Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash'

  • views for non-admins */ add_filter( 'views_edit-page', function( $views ) { if( current_user_can( 'manage_options' ) ) return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

    foreach( (array) $remove_views as $view ) { if( isset( $views[$view] ) ) unset( $views[$view] ); } return $views; } );

/**
 * Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash' 
 * views for non-admins
 */
add_filter( 'views_edit-page', function( $views )
{
    if( current_user_can( 'manage_options' ) )
        return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

    foreach( (array) $remove_views as $view )
    {
        if( isset( $views[$view] ) )
            unset( $views[$view] );
    }
    return $views;
} );

It is working fine. When a user create a page, it is showing only the "mine" option.

But When a new user 1st time come to create a page  (hethey have not created any page); hethey still can view the "All" options where all the published page  (of other users) are shown. Also when hethey delete his all "mine" pages, hethey can view the "All" option.

So how to stop users to see the "all" option when hethey 1st time come to create a page or delete all his page.their pages?

I have a membership website where my users can create their own page. I use below snippets in function.php to remove the options of published, trash etc. of other users and only show "mine".

/**

  • Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash'

  • views for non-admins */ add_filter( 'views_edit-page', function( $views ) { if( current_user_can( 'manage_options' ) ) return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

    foreach( (array) $remove_views as $view ) { if( isset( $views[$view] ) ) unset( $views[$view] ); } return $views; } );

It is working fine. When a user create a page, it is showing only the "mine" option.

But When a new user 1st time come to create a page(he have not created any page); he still can view the "All" options where all the published page(of other users) are shown. Also when he delete his all "mine" pages, he can view the "All" option.

So how to stop users to see the "all" option when he 1st time come to create a page or delete all his page.

I have a membership website where my users can create their own page. I use below snippets in function.php to remove the options of published, trash etc. of other users and only show "mine".

/**
 * Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash' 
 * views for non-admins
 */
add_filter( 'views_edit-page', function( $views )
{
    if( current_user_can( 'manage_options' ) )
        return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

    foreach( (array) $remove_views as $view )
    {
        if( isset( $views[$view] ) )
            unset( $views[$view] );
    }
    return $views;
} );

It is working fine. When a user create a page, it is showing only the "mine" option.

But When a new user 1st time come to create a page  (they have not created any page); they still can view the "All" options where all the published page  (of other users) are shown. Also when they delete his all "mine" pages, they can view the "All" option.

So how to stop users to see the "all" option when they 1st time come to create a page or delete all their pages?

Source Link
Deb
  • 3
  • 3

How to disable users to view Other pages

I have a membership website where my users can create their own page. I use below snippets in function.php to remove the options of published, trash etc. of other users and only show "mine".

/**

  • Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash'

  • views for non-admins */ add_filter( 'views_edit-page', function( $views ) { if( current_user_can( 'manage_options' ) ) return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

    foreach( (array) $remove_views as $view ) { if( isset( $views[$view] ) ) unset( $views[$view] ); } return $views; } );

It is working fine. When a user create a page, it is showing only the "mine" option.

But When a new user 1st time come to create a page(he have not created any page); he still can view the "All" options where all the published page(of other users) are shown. Also when he delete his all "mine" pages, he can view the "All" option.

So how to stop users to see the "all" option when he 1st time come to create a page or delete all his page.