Support

Account

Forum Replies Created

  • When I click “autodetect” in WP All import it shows me that serialized array but filled with data from other post. So I changed coordinates to importer variables like on screenshot attached to previous post.

    “center_lat” and “center_lng” are imported correct but “lat” and “lng” are “undefined”

  • Oh, I have found solution faster than I thought.
    I must use acf/save_post but with 20 priority which runs after saving $_POST data.

    I’m taking subcategory value from post, checking if that term exist and add it to post using wp_set_post_terms.

    Code:

    function my_acf_save_post_after($post_id) {
    
    	require_once('wp-load.php' );
    	require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
    
        // bail early if no ACF data
        if (empty($_POST['acf'])) {
            return;
        }
    
        //get post value
        $parent_cat2 = get_field('curr_categories', $post_id);
        $test_cat2 = get_field('cat_test', $post_id);
    
        $term_id = term_exists( $test_cat, 'category', $parent_cat2 );
    
        wp_set_post_terms( $post_id, $term_id, 'category', true );
    }
    
    // run after ACF saves the $_POST['acf'] data
    add_action('acf/save_post', 'my_acf_save_post', 20);
Viewing 2 posts - 1 through 2 (of 2 total)