使用 acf 表单提交后如何重定向?

How do I redirect after submission with acf form?

如何在使用高级自定义字段表单提交新的 post 后重定向用户?

文档说:

<?php                    
  $args = array(
    'post_id' => 'new_1',
    'field_groups' => array( 357 ),
    'submit_value' => 'Submit Story', 
    'return' => '%post_url%'
   );
   acf_form( $args );
?>

但是我得到一个空白页。

评论后更新,还是空白页:

acf_form(array(
    'post_id'   => 'new_post',
    'post_title'    => true,
    'post_content'  => true,
    'return' => add_query_arg( 'updated', 'true', get_permalink())
));

这个hook函数也试了,还是空白

function my_acf_save_post( $post_id ) {
    wp_redirect(get_permalink($post_id)); exit;
}
add_action('acf/save_post', 'my_acf_save_post', 20);

注意

The post is created tho

问题出在缓冲区

    <?php 
    /* 
    Template Name: Front 
    */ 
    ob_get_clean(); 
    acf_form_head(); 
    get_header(); 
    ?> 
    <div id="content"> 
    <?php 
    acf_form(array( 
    'post_id' => 'new_post', 
    'post_title'    => true, 
    'post_content'  => true, 
    'return' => add_query_arg( 'updated', 'true', home_url() ), 
    )); 
    ?> 
    </div> 
    <?php get_footer(); ?>

有同样的问题,%post_url% 现在似乎出现故障,但不满意 vel 提出的回退到主页。

我需要在编辑后返回 post 页面,并做了以下非常有效的操作:

acf_form(array(
    'post_id'   => $_GET['pid'],
    'return' => get_permalink($_GET['pid'])
));

希望对您有所帮助! 最好的问候

就我而言,我正在构建一个带有 Sage 9 and I had to place the acf_form_head() immediately before the <!doctype html> in my base.php. @Foxaii proposed this solution on the Roots 论坛的网站。