cf_custom_fields_has_pr_processor

Check if a form has the post type processor.

Description

(array|bool) cf_custom_fields_has_pr_processor( (array) $form, (string) $entry_id ); 

Returns (array|bool)

False if not in processor, else post object/ config.

Parameters (2)

0. $form (array)
Form config.
1. $entry_id (string)
The entry id.

Usage

  1. if ( !function_exists( 'cf_custom_fields_has_pr_processor' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-custom-fields/includes/to-post-type.php'; 
  3.  
  4. // Form config. 
  5. $form = array(); 
  6.  
  7. // The entry id. 
  8. $entry_id = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = cf_custom_fields_has_pr_processor($form, $entry_id); 
  12.  

Defined (1)

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

/includes/to-post-type.php  
  1. function cf_custom_fields_has_pr_processor($form, $entry_id) { 
  2. if(!empty($form['processors'])) { 
  3. foreach($form['processors'] as $processor) { 
  4. if($processor['type'] === 'db_storage') { 
  5. $post = get_post($entry_id); 
  6. if(empty($post)) { 
  7. return false; 
  8.  
  9. if($post->post_type === $processor['config']['post_type']) { 
  10. return array( 
  11. 'post' => $post,  
  12. 'config'=> $processor['config'] 
  13. ); 
  14.  
  15. return false;