We have a website that has multiple users who post vans for sale on our site (dealers). after a post is created it shows on our “vans for sale” page although that link is redirected. How can I hide those posts from the page until they are approved by an admin?
Thank you
I’ve tried to change user permissions, tried plugins but they seem to hide the post altogether even after the post is approved.
To hide posts that are not yet approved by an admin on your WordPress website, and ensure they do not appear on the “Vans for Sale” page until approved, you can use the following approach:
function register_custom_post_status() {
register_post_status('pending_approval', array(
'label' => _x('Pending Approval', 'post'),
'public' => false,
'exclude_from_search' => true,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop('Pending Approval <span class="count">(%s)</span>', 'Pending Approval <span class="count">(%s)</span>'),
));
}
add_action('init', 'register_custom_post_status');
function set_default_status($post_data) {
if ($post_data['post_status'] == 'auto-draft') {
$post_data['post_status'] = 'pending_approval';
}
return $post_data;
}
add_filter('wp_insert_post_data', 'set_default_status');
1