bp_registration_deny_access

Check if current user should be denied access or not.

Description

bp_registration_deny_access(); 

Usage

  1. if ( !function_exists( 'bp_registration_deny_access' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bp-registration-options/includes/core.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_registration_deny_access(); 
  7.  

Defined (1)

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

/includes/core.php  
  1. function bp_registration_deny_access() { 
  2.  
  3. $user = new WP_User( get_current_user_id() ); 
  4. $private_network = (bool) get_option( 'bprwg_privacy_network' ); 
  5.  
  6. if ( $private_network ) { 
  7.  
  8. return; 
  9.  
  10. return; 
  11.  
  12. /** 
  13. * Sets up the ability for 3rd parties to do their own redirect based on their own conditions. 
  14. * @since 4.3.0 
  15. * @param array $value Array with keys for whether to redirect and where. 
  16. */ 
  17. $custom_redirect = (array) apply_filters( 'bprwg_custom_redirect', array( 'redirect' => 'false', 'url' => '' ) ); 
  18.  
  19. if ( 'true' === $custom_redirect['redirect'] ) { 
  20. wp_redirect( esc_url( $custom_redirect['url'] ) ); 
  21. exit; 
  22.  
  23. // Not logged in user. 
  24. if ( 0 === $user->ID ) { 
  25.  
  26. /** 
  27. * Filters the URL to redirect to for logged out users. 
  28. * @since 4.3.0 
  29. * @param string $value URL to redirect to. 
  30. */ 
  31. $logged_out_url = apply_filters( 'bprwg_logged_out_redirect_url', get_bloginfo( 'url' ) ); 
  32.  
  33. if ( function_exists( 'is_buddypress' ) && is_buddypress() ) { 
  34. wp_redirect( $logged_out_url ); 
  35. exit; 
  36. if ( function_exists( 'is_bbpress' ) && is_bbpress() ) { 
  37. wp_redirect( $logged_out_url ); 
  38. exit; 
  39.  
  40. // Logged in user but moderated. 
  41. if ( $user->ID > 0 ) { 
  42. if ( bp_registration_get_moderation_status( $user->ID ) ) { 
  43. if ( function_exists( 'is_buddypress' ) && is_buddypress() ) { 
  44.  
  45. /** 
  46. * Filters the URL to redirect to for moderated logged in users and BuddyPress areas. 
  47. * @since 4.3.0 
  48. * @param string $value URL to redirect to. 
  49. */ 
  50. wp_redirect( apply_filters( 'bprwg_bp_logged_in_redirect_url', bp_core_get_user_domain( $user->ID ) ) ); 
  51. exit; 
  52. if ( function_exists( 'is_bbpress' ) && is_bbpress() ) { 
  53.  
  54. /** 
  55. * Filters the URL to redirect to for moderated logged in users and bbPress areas. 
  56. * @since 4.3.0 
  57. * @param string $value URL to redirect to. 
  58. */ 
  59. wp_redirect( apply_filters( 'bprwg_bbp_logged_in_redirect_url', bbp_get_user_profile_url( $user->ID ) ) ); 
  60. exit;