Swiper intro PHP

  1. /*
  2. * Set cookie on first visit
  3. */
  4.  
  5. function app_is_first_time() {
  6. if ( isset($_COOKIE['_wp_first_time']) || is_user_logged_in() ) {
  7. return false;
  8. } else {
  9. // expires in 30 days, you may want to change this
  10. setcookie('_wp_first_time', 1, time() + (WEEK_IN_SECONDS * 4), COOKIEPATH, COOKIE_DOMAIN, false);
  11.  
  12. return true;
  13. }
  14. }
  15.  
  16. add_action( 'init', 'app_is_first_time' );
  17.  
  18. /*
  19. * Show intro screen if it's a first time visit, or user is not logged in
  20. */
  21. function app_show_intro() {
  22. $path=$_SERVER['REQUEST_URI'];
  23. if( strpos($path, 'intro') == true || is_user_logged_in() || isset( $_COOKIE['_wp_first_time'] ) )
  24. return;
  25. wp_redirect( 'http://app.reactordev.com/intro' );
  26. exit;
  27. }
  28.  
  29. add_action( 'init', 'app_show_intro', 999 );
Scott Bolinger