O
O
Orkhan Hasanli2018-06-30 18:36:53
WordPress
Orkhan Hasanli, 2018-06-30 18:36:53

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'	=> 'Опубликовать'
  ));
  
  ?>

Code in functions.php
// 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);
  
  
}

The problem is if the value of the post_content field is set to false in the template, then I can't edit the other fields too... I.e. nothing is entered when entering text... And if true, then everything works accordingly... Although t 'post_content' is only responsible for showing / hiding the form in the front. Maybe this is a bug in the ACF Pro plugin?
PS The CPT (function.php) supports 'title' only. (I don't need an editor...)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-09-22
@racerunner

Maybe it's the version of the plugin? The documentation for it, depending on the version, provides different codes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question