FIX Making offline post unacessible to public
This commit is contained in:
parent
306c82e04c
commit
5c274b005d
|
|
@ -50,7 +50,7 @@ function custom_post_status()
|
||||||
{
|
{
|
||||||
register_post_status('offline', array(
|
register_post_status('offline', array(
|
||||||
'label' => __('Hors ligne', 'metiers-patrimoine-theme'),
|
'label' => __('Hors ligne', 'metiers-patrimoine-theme'),
|
||||||
'public' => true,
|
'public' => false,
|
||||||
'exclude_from_search' => false,
|
'exclude_from_search' => false,
|
||||||
'show_in_admin_all_list' => true,
|
'show_in_admin_all_list' => true,
|
||||||
'show_in_admin_status_list' => true,
|
'show_in_admin_status_list' => true,
|
||||||
|
|
@ -59,7 +59,15 @@ function custom_post_status()
|
||||||
}
|
}
|
||||||
add_action('init', 'custom_post_status');
|
add_action('init', 'custom_post_status');
|
||||||
|
|
||||||
|
// Permettre aux utilisateurs connectés de voir les posts 'offline'
|
||||||
|
function allow_logged_in_users_to_view_offline_posts($query)
|
||||||
|
{
|
||||||
|
if (!is_admin() && $query->is_main_query() && is_user_logged_in()) {
|
||||||
|
$query->set('post_status', array('publish', 'offline'));
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
add_filter('pre_get_posts', 'allow_logged_in_users_to_view_offline_posts');
|
||||||
|
|
||||||
function add_to_post_status_dropdown()
|
function add_to_post_status_dropdown()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user