Support

Account

Home Forums ACF PRO acf_form no data on the frontend for individual field. Reply To: acf_form no data on the frontend for individual field.

  • That is going to be more difficult. The only way I can think of, and I hate to say it, is to set and check a global variable.

    
    // set global
    global $my_current_form;
    // set form to the current form being shown
    $my_current_form = 'form 1';
    // call acf form
    acf_form(....
    
    
    // add to filter
    add_filter('acf/prepare_field/key=field_XXXXXXX', 'hide_acf_field_on_front');
    function hide_acf_field_on_front($field) {
      global $my_current_form ;
      if (is_admin() || $my_current_form == 'form 1')) {
        // allow field in admin
        // allow the field on "form 1"
        return $field;
      }
      // remove field
      return false;
    }