Guest User

Untitled

a guest
Nov 13th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2. /**
  3. * Redirect Specific Tab To Login Page For Non-Logged-in Users.
  4. */
  5. function yzc_rdirect_specific_tabs_to_login_page() {
  6.  
  7. if ( is_user_logged_in() ) {
  8. return;
  9. }
  10.  
  11. // Forbidden Tabs.
  12. $forbidden_slugs = array( 'info', 'friends' );
  13.  
  14. if ( bp_is_user() && in_array( bp_current_component(), $forbidden_slugs ) ) {
  15. // Get Redirection Url
  16. $redirect_url = yz_get_login_page_url();
  17. wp_redirect( $redirect_url );
  18. exit();
  19. }
  20.  
  21. }
  22.  
  23. add_action( 'template_redirect', 'yzc_rdirect_specific_tabs_to_login_page' );
Add Comment
Please, Sign In to add comment