acf_form_head

Acf_form_head().

Description

acf_form_head(); 

This function is placed at the very top of a template (before any HTML is rendered) and saves the $_POST data sent by acf_form.


Usage

  1. if ( !function_exists( 'acf_form_head' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-custom-fields/core/api.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = acf_form_head(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/core/api.php  
  1. function acf_form_head() 
  2. // global vars 
  3. global $post_id; 
  4.  
  5.  
  6. // verify nonce 
  7. if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') ) 
  8. // $post_id to save against 
  9. $post_id = $_POST['post_id']; 
  10.  
  11.  
  12. // allow for custom save 
  13. $post_id = apply_filters('acf/pre_save_post', $post_id); 
  14.  
  15.  
  16. // save the data 
  17. do_action('acf/save_post', $post_id);  
  18.  
  19.  
  20. // redirect 
  21. if(isset($_POST['return'])) 
  22. wp_redirect($_POST['return']); 
  23. exit; 
  24.  
  25.  
  26. // needwpstyling 
  27. wp_enqueue_style(array( 
  28. 'colors-fresh' 
  29. )); 
  30.  
  31.  
  32. // actions 
  33.  
  34. add_action('wp_head', 'acf_form_wp_head'); 
  35.