Support

Account

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;
    
    });