Limit post display to post authors and create an exception for specific pages
Question
I’m trying to limit the display of the content to authors and need to make specific pages viewable by everyone (i.e Dashboard / Data entry …)
Any suggestions on how to add specific rules to display specific pages to all logged-in users?
Thanks a bunch
//limit post display to post authors (excludes admins)
function shapeSpace_set_only_author($query) {
global $current_user;
if (!current_user_can('manage_options')) {
$query->set('author', $current_user->ID);
}
}
add_action('pre_get_posts', 'shapeSpace_set_only_author');
0
content-restriction, user-access
4 years
2020-03-30T08:50:50-05:00
2020-03-30T08:50:50-05:00 0 Answers
87 views
0
Leave an answer