Answer the question
In order to leave comments, you need to log in
Why is it impossible to edit text in the front-end ACF form?
Good afternoon!
Faced a strange case in ACF. Previously, this problem was not observed. I use acf_form() to post stuff through the front end.
Template code:
<?php
acf_form(array(
'post_id' => 'new_post',
'post_title' => false,
'post_content' => false,
'new_post' => array(
'post_type' => 'testimonial',
'post_status' => 'draft'
),
'return' => home_url('thank-you'),
'submit_value' => 'Опубликовать'
));
?>
// frontend form for adding testimonials
add_action('acf/save_post', 'testimonial_save_post');
function testimonial_save_post( $post_id ) {
// bail early if not a testimonial post
if( get_post_type($post_id) !== 'testimonial' ) {
return;
}
// bail early if editing in admin
if( is_admin() ) {
return;
}
// vars
$post = get_post( $post_id );
// get custom fields (field group exists for content_form)
$testimonial_text = get_field('testimonial_text', $post_id);
$testimonial_name = get_field('testimonial_name', $post_id);
$testimonial_work = get_field('testimonial_work', $post_id);
$testimonial_profession = get_field('testimonial_profession', $post_id);
$testimonial_link = get_field('testimonial_link', $post_id);
$testimonial_phone = get_field('testimonial_phone', $post_id);
$testimonial_email = get_field('testimonial_email', $post_id);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question