I just wrote some code to do something a bit different, but it should work for what you’re trying to do. It’s hooked in at the wp
hook, which will prevent redirect loop errors. This will go in either a functions.php file or your own custom plugin (recommended).
add_action('wp','restrictEnterSite');
function restrictEnterSite(){
// Make a template of the splash page you'd like to display if user is not logged in
$homeURL = home_url('/splash-template.php');
//validate
if ( $homeURL !== $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] && !is_user_logged_in() ) {
wp_redirect($homeURL);
exit;
}
}
Give this a shot!
Related Posts:
- Remove username in emails or swap username for email
- Menu not updating for logged in users after redirect
- User registration followed by automatic login
- Adding “Remember Me” in custom login
- How to change the wp-login.php page title?
- How build a custom login/register form with error handling?
- Change the footer text on the login page
- Changing user_nicename
- the_post_thumbnail() based on the Post ID
- Add Adsense code in index.php
- WordPress 4 invalid username special charachters issue
- How to place login logout link on menu that redirects users back to current page?
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- How to resolve error “Cookies are blocked due to unexpected output.”?
- Using a nonce in a Custom Login Form
- How to remove this function from the homepage?
- Constructing a custom login form using ajax
- automated tests as a user?
- woocommerce and is_user_logged_in() if not redirect to homepage
- Help with adding pagination to custom wp_query
- How to display recent posts on home page with custom HTML
- Check if user is logged in when clicking certain links on certain pages
- PHP If user is logged in & on home page redirect
- WordPress shows registration link for non logged users
- Creating login session via CURL
- Admin username and password
- How can I hide Home in my menu in a specific page?
- Recovering WP Login Credintials in Code?
- Is it necessary to sanitize wp_set_password user input?
- WordPress custom login form using Ajax
- How to give new users two specific user role options upon WordPress user registration
- Displaying the last post on static homepage
- Wp-login appears White Screen, Error: Cannot modify header information
- How to: PHP Log Out Link?
- Login/logout in header
- Reordering Buddy Press profile navigation [closed]
- Why is my cookie not unsetting upon logout? [closed]
- User management system similar to wordpress one?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- Programmatic Login from 3rd Party site
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- How do I programmatically set a user as spam in BuddyPress? [closed]
- How to debug my custom login form looping intermittently
- getting logged in user info (wp-load.php) from parent directory
- Let Users Choose Post Categories
- Problem with login form
- Login to wordpress by clicking a link and specifying usernaname and password in url
- two columns of posts on homepage, one of them “favorites”
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- I restricted wordpress by logged users. It’s possible exclude a page?
- Log in / Log Out Custom Button
- WordPress Stripping Colons?
- Should `wp_login` be used since it’s deprecated?
- How to redirect users based on role and content of redirect_to?
- Change CSS based on is_user_logged_in
- How to display login form anywhere, when user isn’t logged in, without redirecting?
- How can I open up my administrative panel to everyone?
- Buddypress update user avatar image via REST
- Pagination broken on is_front_page()
- How to include custom code on a page that’s set to act as homepage?
- How can I add a new row in a separate database when someone registers via WordPress?
- After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source
- One account with multiple logins
- Lost in trying to create user database system
- Shortcode to log user into current URL
- Amend theme php to include certain category in header
- show recent posts php code error?
- PHP getting error when trying to access WP-Admin Dashboard
- I installed WordPress locally now how do I login?
- If user is logged in not working
- Why BuddyPress fields not saving?
- How to do something when user profile rendereing?
- implementing a jQuery “click to expand” link in WordPress [closed]
- is user member of a group, show them categories [closed]
- Show login greeting above sub-menu links?
- Wp favorites posts by specific category? [closed]
- Display multi-select box choices in a bullet list [closed]
- page 1 is not paged
- is_user_logged_in returning nothing on custom page
- Customize Buddypress adminbar [closed]
- Help with accessing wp-admin page and resolving error messages
- Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Check if user had autologin & if so, logout
- Admin Panel 404 Error after login
- copy fields value to another field
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- How to block specific user id in custom login form?
- Log out without confirmation request (nonce)
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- Restrict wordpress access to logged users only
- Link to index.php from home.php?
- Infinite loop when logging out using custom login form
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Issues adding Recaptcha v3 to WordPress Registration
- Display specific page if user signed in
- Change Login or Logout text based on status