rcp_bbp_save_meta_data

The Restrict Content Pro - bbPress rcp bbp save meta data function.

Description

rcp_bbp_save_meta_data( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

  1. if ( !function_exists( 'rcp_bbp_save_meta_data' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'restrict-content-pro-bbpress/includes/metaboxes.php'; 
  3.  
  4. // The post id. 
  5. $post_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = rcp_bbp_save_meta_data($post_id); 
  9.  

Defined (1)

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

/includes/metaboxes.php  
  1. function rcp_bbp_save_meta_data( $post_id ) { 
  2.  
  3. // verify nonce 
  4. if ( ! isset( $_POST['rcpb_meta_box'] ) || ! wp_verify_nonce( $_POST['rcpb_meta_box'], basename( __FILE__ ) ) ) { 
  5. return $post_id; 
  6.  
  7. // check autosave 
  8. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { 
  9. return $post_id; 
  10.  
  11. // check permissions 
  12. if ( ! current_user_can( 'edit_post', $post_id ) ) { 
  13.  
  14. return $post_id; 
  15.  
  16.  
  17. foreach ( rcp_bbp_get_metabox_fields() as $field ) { 
  18.  
  19. if ( isset( $_POST[ $field['id'] ] ) ) { 
  20.  
  21. $old = get_post_meta( $post_id, $field['id'], true ); 
  22. $data = $_POST[ $field['id'] ]; 
  23.  
  24. if ( ( $data || $data == 0 ) && $data != $old ) { 
  25.  
  26. update_post_meta( $post_id, $field['id'], $data ); 
  27.  
  28. } elseif ( '' == $data && $old ) { 
  29.  
  30. delete_post_meta( $post_id, $field['id'], $old ); 
  31.  
  32.  
  33. } else { 
  34.  
  35. delete_post_meta( $post_id, $field['id'] ); 
  36.  
  37.  
  38.