Guest User

Untitled

a guest
Jun 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // Show app-data posts only to app users
  2. function user_redirect()
  3. {
  4. if ( is_category( 'app-data' ) ) {
  5. $url = site_url();
  6. wp_redirect( $url );
  7. exit();
  8. }
  9. }
  10. add_action( 'the_post', 'user_redirect' );
  11.  
  12. function redirect_not_app_users_if_app_data_category() {
  13. if ( (is_category( 'app-data' ) || in_category('app-data'))&& ! is_user_logged_in() ) {
  14. wp_redirect( home_url() );
  15. die;
  16. }
  17. }
  18. add_action( 'template_redirect', 'redirect_not_app_users_if_app_data_category');
  19.  
  20. add_action( 'template_redirect', 'wpse_restrict_catgorey');
  21. function wpse_restrict_catgorey(){
  22.  
  23. if( ! is_user_logged_in() && is_category( 'app-data' ) ) {
  24. wp_redirect( home_url() );
  25. exit;
  26. }
  27. }
Add Comment
Please, Sign In to add comment