Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tefon

    (@tefon)

    Hello,

    In the code below, I want to automatically retrieve the “$field_name” field I’ve highlighted in code bold. How can I do this? I’m not sure, but I think this field is already in “$_POST[‘acf’],” thanks.

    Have a nice day.

    function tef1011( $post_id = 0, $values = null, $field = true ) {
        if ( ! empty( $_POST['acf'] ) ) {
            acf_update_values( $_POST['acf'], $post_id );
        }

        // Replace 'speciality' with your field name
        $term_id = intval(filter_var($post_id, FILTER_SANITIZE_NUMBER_INT));
        $field_name = 'speciality';

        // Get the raw field value (this will be an array for multiple select)
        $values = get_field($field_name, $post_id, false);

        // Insert each value as its own row
        foreach ($values as $value) {        
            add_metadata('term', $term_id, $field_name, $value);  
        }
    }

    add_action('acf/save_post', 'tef1011', 20);
    Thread Starter tefon

    (@tefon)

    The answer came:

    “Hi Thanks for getting in touch.

    We’re happy to help, but this is the pre-sales channel, not technical support.”

    Can you help from here?

Viewing 2 replies - 1 through 2 (of 2 total)