Posted By

labsecrets on 06/19/10


Tagged


Versions (?)

Add A Private Page Template


 / Published in: HTML
 

  1. STEP ONE:
  2.  
  3. If you want to make your own private page template, using your own theme,
  4. simply open your existing "page.php" file in a text editor, then save a copy
  5. of it with the name "template-private-page.php".
  6.  
  7. Then, at the very top of the new template page, add the following code snip:
  8.  
  9. <?php
  10. /*
  11. Template Name: Private Page
  12. */
  13. ?>
  14. <?php do_action( 'walled_page' ) ?>
  15.  
  16.  
  17. STEP TWO:
  18.  
  19. Open up your "functions.php" file and at the very bottom,
  20. add the following code (be sure you put it just above the "?>"
  21. closing bracket:
  22.  
  23.  
  24. /* This makes a function to be used on private page template */
  25.  
  26. function sh_walled_page()
  27. {
  28. global $bp;
  29.  
  30. if (bp_is_register_page() || bp_is_activation_page())
  31. return;
  32.  
  33. if(!is_user_logged_in()) {
  34. bp_core_redirect( $bp->root_domain .'/unavailable');
  35. }
  36. }
  37.  
  38. add_action( 'walled_page', 'sh_walled_page' );

Report this snippet  

You need to login to post a comment.