bpbbpst_edit_support_type

Hooks bbp_edit_topic_post_extras to update the support status when topic is edited.

Description

bpbbpst_edit_support_type( (int) $topic_id = 0 ); 

Parameters (1)

0. $topic_id — Optional. (int)
The id of the topic

Usage

  1. if ( !function_exists( 'bpbbpst_edit_support_type' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddy-bbpress-support-topic/includes/functions.php'; 
  3.  
  4. // the id of the topic 
  5. $topic_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bpbbpst_edit_support_type($topic_id); 
  9.  

Defined (1)

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

/includes/functions.php  
  1. function bpbbpst_edit_support_type( $topic_id = 0 ) { 
  2.  
  3. if ( empty( $_POST['_wpnonce_bpbbpst_support_define'] ) || ! wp_verify_nonce( $_POST['_wpnonce_bpbbpst_support_define'], 'bpbbpst_support_define' ) ) { 
  4. return; 
  5.  
  6. if ( ! empty( $_POST['_bp_bbp_st_is_support'] ) ) { 
  7. $support = get_post_meta( $topic_id, '_bpbbpst_support_topic', true ); 
  8.  
  9. $support = empty( $support ) ? 1 : $support; 
  10. update_post_meta( $topic_id, '_bpbbpst_support_topic', $support ); 
  11. } else { 
  12. $support = get_post_meta( $topic_id, '_bpbbpst_support_topic', true ); 
  13.  
  14. if ( ! empty( $support ) ) { 
  15. delete_post_meta( $topic_id, '_bpbbpst_support_topic' ); 
  16.