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
- WordPress 4 invalid username special charachters issue
- How to place login logout link on menu that redirects users back to current page?
- 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?
- Help with adding pagination to custom wp_query
- How to display recent posts on home page with custom HTML
- PHP If user is logged in & on home page redirect
- WordPress shows registration link for non logged users
- Admin username and password
- 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
- 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]
- Programmatic Login from 3rd Party site
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- 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
- 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
- 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?
- 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
- 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?
- Display multi-select box choices in a bullet list [closed]
- 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
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- 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
- 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
- Refresh page after login with litespeed cache
- Having trouble with customizing blog posts on the home page
- Redirect after login depending on the URL
- How do I visualize the author’s post from the front end?
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Redirecting the lost password page request when using a custon login page
- How do I send a POST request with params with WordPress REST API
- wp-login.php?redirect_to=https problem
- is_user_logged_in() not working in homepage
- Check if a user is logged into my WordPress site which is on a different server
- how to get buddy press messages based on thready_id?
- Newbie question. Login/Registration. New PHP page
- Different home page for logged off users
- Insert div after every three posts in home.php [duplicate]
- Adding a sidebar to wp-login.php
- Create a dynamic buddupress tab
- List users in a dropdown for login
- How to display html code on homepage
- White screen after login attempt
- Get string from array and start loop [closed]
- I want Page titles and excerpts to show up on home.php in certain order
- 2 small questions: How to redirect to a created page & show that pages title in wp, bp
- How to replace wp-admin login page to another location?
- Check user last login date
- Prevent users from display default wordpress login form
- login redirect based on user role not work as expected
- How to change wp-admin and wp-login urls
- change div text and link for logged in users