Home Forums Backend Issues (wp-admin) Get acf/save_post to fire on Quick Edit


Get acf/save_post to fire on Quick Edit

  • Edit:
    never mind, I’ve figured a totally different approach therefore this is not needed anymore ๐Ÿ™‚

    Hey guys, let me first say that I’m no super pro coder and I’ve been trying to google for a solution for three days now.

    I’m firing a function that grabs a custom field’s value from the post object selected on the custom post and puts it in a new custom field in the actual post.


    • I have a custom post type named ‘course’
    • I have a custom post type named ‘tutors’
    • ‘course’ has an image field where I upload the icon related to the course (eg a note for the Music course)
    • ‘tutors’ has a Post Object field where I select the course the tutor belongs to (so for a Music tutor, I will select the Music ‘course’ in the dropdown.
    • Now what I’m trying to do, is to store the icon’s url in the ‘tutors’ post type, by updating a custom field’s value in the ‘tutors’ cpt.

      I’ve been successfully able to achieve that by putting this code in my functions.php:

       // Populate course_icon on Tutor save
      function acf_save_post_data( $post_id ) {
        $post_type = get_post_type( $post_id );
        if ($post_type != 'tutors') {
        $tutor_course = get_field('tutor_course'); // The post object dropdown field
        $post = $tutor_course;
        $icon = get_field('course_icon', $post->ID); // The icon URL from the selected Course
        update_field( 'icon_field_on_tutor_page', $icon, $post_id ); // The new field on the tutor page that stores the icon's URL
      add_action( 'acf/save_post', 'acf_save_post_data', 20); //priority of 20 makes the function run at low priority

      But the problem is that it only works when I hit publish/update on the single Tutor, while I would like it to update the custom field also when bulk selecting the Tutors and clicking on Update. It just doesn’t update the value, so I guess acf/save_post works only when editing the single tutor and not in bulk?

      The reason why I need this is because if I edit the ‘course’ icon, I have to update all the ‘tutors’ in order for the new icon’s URL to appear in the custom field.

      If there is any other solution, I’m open to it, just keep in mind I’m not extremely skilled and took me 2 days to put this piece of code together.

      Sorry if this code looks like crap to you (it probably will!) but I’m trying to learn as hard as I can.

      Thanks a LOT!

  • I’m trying to do exactly this, and I’d love to know what approach you took where you didn’t need this anymore!

  • I didn’t see this when it originally came up, but when reading it time my initial reaction was “Why duplicate all those references?”

    There is a relationship using the post object field from the tutor to the course. Get the post ID of the related field from the course and then get the icon from the turor.

    this may or may not work exactly as written, it’s just a quick example.

    $course_id = get_field('post_object_field_name');
    $icon = get_field('icon_field_name', $post_id);
  • The Solutions in replies helped me also as i was facing this problems. Thanks for the sharing solution with us.

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

You must be logged in to reply to this topic.