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?