The is_login_page()
function is taken from here
function is_login_page() {
if ( $GLOBALS['pagenow'] === 'wp-login.php' && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] === 'register' )
return true;
return false;
}
function my_redirect() {
//if you have the page id of landing. I would tell you to use if( is_page('page id here') instead
//Don't redirect if user is logged in or user is trying to sign up or sign in
if( !is_login_page() && !is_admin() && !is_user_logged_in()){
//$page_id is the page id of landing page
if( !is_page($page_id) ){
wp_redirect( get_permalink($page_id) );
exit;
}
}
}
add_action( 'template_redirect', 'my_redirect' );
Related Posts:
- Redirect a list of URLs to another URL, using functions.php
- is_user_logged_in not working to redirect only logged out users
- Php function 301 redirect
- Using wp_redirect and .htaccess to re-route searches (and pass along the remaining GET vars)
- Cannot modify header information – headers already sent (wp_redirect in functions.php)
- Redirect website domain (including all pages) to external URL after Popup message (few seconds)
- How to add array [closed]
- Remove attachment page for audio media type only
- A blank page is shown after I add a Function
- Making an under maintenance page (without using plugins)
- get php variable from functions php and echo it in theme template files [closed]
- paginate_links() don’t properly work in search.php?
- How to influence the information displayed on widget inside wp-admin
- Remove Container Element From wp_nav_menu() Markup
- WordPress function like is_category for subcategory? is_subcategory?
- How can I get $id variable in widget’s form function?
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- Does WordPress Development Mode Exist (with not minified JS)?
- wp_delete_user with username
- what is the meaning of settings_fields()
- Organize functions.php
- How to activate “Description” metabox for menu item programmatically?
- Change labels on ‘Nickname’ and ‘Biographical Info’ in user-edit.php
- How to set child post categories to parent post categories when updating parent post?
- get excerpt without images
- Display height and width properties with the_post_thumbnail() or related function
- change default option in wp_dropdown_categories
- Display a text message if the shortcode is found?
- How to store / access files in child theme folder
- How to use IF Statement in WordPress?
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- Use of undefined constant bloginfo
- Change size and crop medium_large images
- Ninja form Redirect depending on text field content [closed]
- Display Password Protected external RSS in wordpress template
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- Problem only while using require_once() within functions.php
- How to force field validation first, then its values saved durning edit profile?
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- How to properly remove style for non logged in and front page only
- WordPress converts media extention URL automatically to video player
- How do you Permanently Delete Sidebars
- Add a unique class to HTML tag/element
- Allow Contributor to edit their own posts after Adm aproval
- help I changed one currency in woocommerce and everything is ruined [closed]
- How to run a function in every page, every device
- Which function required?
- How to ignore posts in pre_get_posts?
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- New functions in separate directory — better, portable way
- WordPress Migration error phpupdate_option is not a function
- Custom Query Not Paginating
- Solved: redirect to another page using functions.php
- Getting the teaser text without overriding global variables
- Ajax resetting my global variable
- Problem enqueuing scripts on not single posts
- referencing the current user in a page i created in wordpress
- is_main_query() always returning false
- Undefined variable issue for wp_get_attachment_image_url
- Counting posts and trigger it [closed]
- ACF Flexible in TCPDF
- How do i tweak my wp Post title base on category of the post
- Why isn’t comment validation working?
- modifying every other element’s class inside while loop
- Adding Custom Body Class for Page: Shop
- Detect what link user clicks and Redirect to a specific page for logged in users only
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- Change ‘Categories’ to ‘Topics’
- Is it possible to use ‘wp_insert_post’ function within a for loop?
- save_post function keeps triggering: Warning: array_map(): Argument #2 should be an array… when restoring from trash
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- Code I am placing in the wp_footer is going outside the entire HTML frame!
- Restoring pages in wordpress
- Redirect after login to current URL
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Best way to add image to recent posts widget?
- Different body image backgrounds on different pages, posts and categories
- Hide certain post types from editors
- Language switcher for subdomains
- Function to draw random image from specified category destroys site logic – why?
- Issues with add_query_arg() not passing a variable
- Add Function For Instances of Custom Text in Multiple Category IDs to display in post content
- Move captions under gallery images in twenty fourteen theme
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- How to add a class name to the ancestor of a post?
- Undefined offset: 2
- is_user_logged_in() isn’t working
- Retrive post by tags PHP code
- Sorting date results from a query
- Using is_plugin_active within functions.php
- Button generate a random URL [closed]
- Add custom css to theme
- How do I add functionality to images?
- Why don’t ‘wp_nav_menu’ CSS classes work until a menu is created?