Support

Account

Home Forums Backend Issues (wp-admin) acf/save_post only working after save on backend

Solving

acf/save_post only working after save on backend

  • I’ve created a function to updated the post title and post name within a form.

    add_action('acf/save_post', 'chiwp_update_post_name', 20);
    
    function chiwp_update_post_name($post_id)
    {
      $desired_url = get_field('show_information', $post_id);
      $desired_url = $desired_url['desired_url_extension'];
      $title = get_field('show_information', $post_id);
      $title = $title['show_name'];
    
      $data = array(
        'ID'         => $post_id,
        'post_title' => $title,
        'post_name'  => sanitize_title($desired_url),
      );
    
      wp_update_post($data);
    }

    However, the front end displays only the new title and slug info correctly initially.

    In other words, all the other form data is saved to the back end correctly, but it does not appear on the front end until I manually “save draft” in the admin. Then everything works properly.

    What am I missing within the function to save all the data at the right time?

  • Did you ever get an answer to this?

  • save post action but not on post creation?

  • solved this? I want to make the download from frontend and same function.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘acf/save_post only working after save on backend’ is closed to new replies.