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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.