Home › Forums › Backend Issues (wp-admin) › Meta Boxes missing › Reply To: Meta Boxes missing
I think I got this solved.
I have created the fields with the Admin user (user_id == 1) and the field appeared when I modified the query to include the Admin user_id. Here is the code I’m using now to prevent other users from seeing others posts and displays the fields on post.php page.
add_filter('pre_get_posts', function($query) {
if ($query->is_admin) {
global $user_ID;
global $pagenow;
$allowedPages = ['post.php', 'post-new.php', 'admin-ajax.php'];
if (in_array($pagenow, $allowedPages)) {
$query->set('author__in', [$user_ID, 1]);
} else {
$query->set('author', $user_ID);
}
}
return $query;
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.