Контент страницы виден только если юзер залогиненный, WORDPRESS
Если я загружаю страницу от имени админа или другого зарегистрированного пользователя, контент отображается нормально, но если я выйду с аккаунта, то контент исчезает.
Вот код
acf_form_head();
get_header(); ?>
<div class="container" style="margin-top: 94px; height: 0; overflow: hidden;"><?php
// =====================================================================================
// UPDATE: A better method for both frontend submission and editing is available here
// https://itsmereal.com/frontend-post-submission-edit-advanced-custom-fields/
// =====================================================================================
// ======================================================================================
// Codes to put on your page template header
// Remember, the above piece of code needs to be placed between <?php and get_header();
// ======================================================================================
add_action( 'get_header', 'tsm_do_acf_form_head', 1 );
function tsm_do_acf_form_head() {
// Bail if not logged in or not able to post
// if ( ! ( is_user_logged_in() || current_user_can('publish_posts') ) ) {
// return;
// }
acf_form_head();
}
/**
* Deregister the admin styles outputted when using acf_form
*/
add_action( 'wp_print_styles', 'tsm_deregister_admin_styles', 999 );
function tsm_deregister_admin_styles() {
// Bail if not logged in or not able to post
// if ( ! ( is_user_logged_in() || current_user_can('publish_posts') ) ) {
// return;
// }
wp_deregister_style( 'wp-admin' );
}
// ======================================================================================
// Codes to put on your content body area
// ======================================================================================
// Bail if not logged in or able to post
// if ( ! ( is_user_logged_in()|| current_user_can('publish_posts') ) ) {
// echo '<p>You must be a registered author to post.</p>';
// return;
// }
$current_user = wp_get_current_user();
$new_post = array(
'post_id' => 'new_post',
'post_author' => $current_user->display_name;
'field_groups' => array(452, 470), // Used ID of the field groups here.
'post_title' => true, // This will show the title filed
'post_content' => false, // This will show the content field
'form' => true,
'new_post' => array(
'post_type' => 'post',
'post_status' => 'draft' // You may use other post statuses like draft, private etc.
),
'return' => '%post_url%',
'submit_value' => 'Submit Book',
);
acf_form( $new_post);
?>