ACF不保存数据,只显示正面WordPress的微调器


ACF not saving data and only showing spinner from front side wordpress

>我在正面显示了 ACF 表单,现在尝试保存数据,但它旋转加载而不是保存帖子。我正在尝试下面的代码。我做错了什么

<?php
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();
}
add_shortcode( 'intake_form', 'intake_form_open' );
function intake_form_open($atts) {
// 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;
    }
?> 
    <div id="personal-information">
        <?php
        $edit_post = array(
            'post_id'            => 'new', // Create a new post
        // PUT IN YOUR OWN FIELD GROUP ID(s)
            'field_groups'       => array($atts['id']), // Create post field group ID(s)
            'form'               => true,
            'return'             => '%post_url%', // Redirect to new post url
            'html_before_fields' => '',
            'html_after_fields'  => '',
            'submit_value'       => 'Submit Post',
            'updated_message'    => 'Saved!'
        );
        acf_form( $edit_post );
        ?>
    </div>
<?php
}
add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post', 10, 2 );
function tsm_do_pre_save_post( $post_id ) {
    // Bail if not logged in or not able to post
    if ( ! ( is_user_logged_in() || current_user_can('publish_posts') ) ) {
        return;
    }
    // check if this is to be a new post
    if( $post_id != 'new' ) {
        return $post_id;
    }
    // Create a new post
    $post = array(
        'post_type'     => 'post', // Your post type ( post, page, custom post type )
        'post_status'   => 'private', // (publish, draft, private, etc.)
        'post_title'    => 'Comments ACF Form', // Post Title ACF field key
        'post_content'  => $_POST['acf']['field_56badad4fb425'], // Post Content ACF field key
    );
    // insert the post
    $post_id = wp_insert_post( $post );
    // Save the fields to the post
    do_action( 'acf/save_post' , $post_id );
    return $post_id;
}
?>

ACF 或其他插件在后端抛出错误。在 wordpress 中打开调试,然后检查错误日志中的问题。

请检查以确保您没有启用任何其他前端页面发布插件。当WP前端插件也启用时,我遇到了同样的问题。

一旦我禁用它,一切正常。