Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. if( ! function_exists( 'marstheme_redirect_nonemember_to' ) ){
  2.     /**
  3.      * Redirect the none-member to another page if they visit the video post.
  4.      */
  5.     function marstheme_redirect_nonemember_to() {
  6.            
  7.         $redirect_to = ''; // The destination link or page id goes here, example: http://example.com, or 123.
  8.  
  9.         if( absint( $redirect_to ) ){
  10.             $redirect_to = get_permalink( $redirect_to );
  11.         }
  12.            
  13.         if( is_singular( 'video' ) && !is_user_logged_in() ){
  14.             wp_redirect( esc_url( $redirect_to ) ); exit;
  15.         }
  16.     }
  17.     add_action( 'wp' , 'marstheme_redirect_nonemember_to');
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement