Support

Account

Home Forums General Issues Can’t send a string via REST API into a select field Reply To: Can’t send a string via REST API into a select field

  • Due to the lack of answers here, I had to find a way to make this happen so I ended up simply adding it to the standard REST like so:

    function save_custom_meta_from_rest( $post, $request, $creating ) {
        $params = $request->get_json_params();
        
        if ( isset( $params['observacao_intensidade_ataque'] ) ) {
            update_post_meta( $post->ID, 'observacao_intensidade_ataque', sanitize_text_field( $params['observacao_intensidade_ataque'] ) );
        }
    
        if ( isset( $params['observacao_incidencia_doenca_parcela'] ) ) {
            update_post_meta( $post->ID, 'observacao_incidencia_doenca_parcela', sanitize_text_field( $params['observacao_incidencia_doenca_parcela'] ) );
        }
    }
    add_action( 'rest_insert_observacao', 'save_custom_meta_from_rest', 10, 3 );

    Hope this helps future people with the same problem.

    I just have now to put these two fields outside “acf” and that’s it.