rcp_hide_single_topic

The Restrict Content Pro - bbPress rcp hide single topic function.

Description

rcp_hide_single_topic(); 

Usage

  1. if ( !function_exists( 'rcp_hide_single_topic' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'restrict-content-pro-bbpress/includes/topic-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rcp_hide_single_topic(); 
  7.  

Defined (1)

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

/includes/topic-functions.php  
  1. function rcp_hide_single_topic() { 
  2.  
  3. $topic_id = get_the_ID(); 
  4. $post_type = get_post_type( $topic_id ); 
  5.  
  6. if( ! function_exists( 'bbp_get_topic_post_type' ) ) { 
  7.  
  8. return; 
  9.  
  10.  
  11. if( bbp_get_topic_post_type() !== $post_type ) { 
  12.  
  13. return; 
  14.  
  15.  
  16. if ( rcp_bbp_can_access_forum( bbp_get_forum_id() ) ) { 
  17.  
  18. return; 
  19.  
  20.  
  21. if( is_user_logged_in() ) { 
  22.  
  23. $redirect = home_url(); 
  24.  
  25. } else { 
  26.  
  27. $redirect = bbp_get_topic_permalink( bbp_get_topic_id( $topic_id ) ); 
  28.  
  29. wp_redirect( home_url( 'wp-login.php?redirect_to=' . urlencode( $redirect ) ) ); exit;