bbp_get_form_topic_subscribed

Return checked value of topic subscription.

Description

(string) bbp_get_form_topic_subscribed(); 

Returns (string)

Checked value of topic subscription


Usage

  1. if ( !function_exists( 'bbp_get_form_topic_subscribed' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bbp_get_form_topic_subscribed(); 
  7.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_form_topic_subscribed() { 
  2.  
  3. // Get _POST data 
  4. if ( bbp_is_post_request() && isset( $_POST['bbp_topic_subscription'] ) ) { 
  5. $topic_subscribed = (bool) $_POST['bbp_topic_subscription']; 
  6.  
  7. // Get edit data 
  8. } elseif ( bbp_is_topic_edit() || bbp_is_reply_edit() ) { 
  9.  
  10. // Get current posts author 
  11. $post_author = bbp_get_global_post_field( 'post_author', 'raw' ); 
  12.  
  13. // Post author is not the current user 
  14. if ( bbp_get_current_user_id() !== $post_author ) { 
  15. $topic_subscribed = bbp_is_user_subscribed_to_topic( $post_author ); 
  16.  
  17. // Post author is the current user 
  18. } else { 
  19.  
  20. // Get current status 
  21. } elseif ( bbp_is_single_topic() ) { 
  22.  
  23. // No data 
  24. } else { 
  25. $topic_subscribed = false; 
  26.  
  27. // Get checked output 
  28. $checked = checked( $topic_subscribed, true, false ); 
  29.  
  30. return apply_filters( 'bbp_get_form_topic_subscribed', $checked, $topic_subscribed );