Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Change homepage content if user is logged in – BuddyPress

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:

  1. Remove username in emails or swap username for email
  2. Menu not updating for logged in users after redirect
  3. User registration followed by automatic login
  4. Adding “Remember Me” in custom login
  5. How to change the wp-login.php page title?
  6. How build a custom login/register form with error handling?
  7. Change the footer text on the login page
  8. Changing user_nicename
  9. the_post_thumbnail() based on the Post ID
  10. Add Adsense code in index.php
  11. WordPress 4 invalid username special charachters issue
  12. How to place login logout link on menu that redirects users back to current page?
  13. How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
  14. How to resolve error “Cookies are blocked due to unexpected output.”?
  15. Using a nonce in a Custom Login Form
  16. How to remove this function from the homepage?
  17. Constructing a custom login form using ajax
  18. automated tests as a user?
  19. woocommerce and is_user_logged_in() if not redirect to homepage
  20. Help with adding pagination to custom wp_query
  21. How to display recent posts on home page with custom HTML
  22. Check if user is logged in when clicking certain links on certain pages
  23. PHP If user is logged in & on home page redirect
  24. WordPress shows registration link for non logged users
  25. Creating login session via CURL
  26. Admin username and password
  27. How can I hide Home in my menu in a specific page?
  28. Recovering WP Login Credintials in Code?
  29. Is it necessary to sanitize wp_set_password user input?
  30. WordPress custom login form using Ajax
  31. How to give new users two specific user role options upon WordPress user registration
  32. Displaying the last post on static homepage
  33. Wp-login appears White Screen, Error: Cannot modify header information
  34. How to: PHP Log Out Link?
  35. Login/logout in header
  36. Reordering Buddy Press profile navigation [closed]
  37. Why is my cookie not unsetting upon logout? [closed]
  38. User management system similar to wordpress one?
  39. Show css depending on activity type in BuddyPress activity-loop [closed]
  40. Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
  41. Programmatic Login from 3rd Party site
  42. Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
  43. How do I programmatically set a user as spam in BuddyPress? [closed]
  44. How to debug my custom login form looping intermittently
  45. getting logged in user info (wp-load.php) from parent directory
  46. Let Users Choose Post Categories
  47. Problem with login form
  48. Login to wordpress by clicking a link and specifying usernaname and password in url
  49. two columns of posts on homepage, one of them “favorites”
  50. Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
  51. I restricted wordpress by logged users. It’s possible exclude a page?
  52. Log in / Log Out Custom Button
  53. WordPress Stripping Colons?
  54. Should `wp_login` be used since it’s deprecated?
  55. How to redirect users based on role and content of redirect_to?
  56. Change CSS based on is_user_logged_in
  57. How to display login form anywhere, when user isn’t logged in, without redirecting?
  58. How can I open up my administrative panel to everyone?
  59. Buddypress update user avatar image via REST
  60. Pagination broken on is_front_page()
  61. How to include custom code on a page that’s set to act as homepage?
  62. How can I add a new row in a separate database when someone registers via WordPress?
  63. 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
  64. One account with multiple logins
  65. Lost in trying to create user database system
  66. Shortcode to log user into current URL
  67. Amend theme php to include certain category in header
  68. show recent posts php code error?
  69. PHP getting error when trying to access WP-Admin Dashboard
  70. I installed WordPress locally now how do I login?
  71. If user is logged in not working
  72. Why BuddyPress fields not saving?
  73. How to do something when user profile rendereing?
  74. implementing a jQuery “click to expand” link in WordPress [closed]
  75. is user member of a group, show them categories [closed]
  76. Show login greeting above sub-menu links?
  77. Wp favorites posts by specific category? [closed]
  78. Display multi-select box choices in a bullet list [closed]
  79. page 1 is not paged
  80. is_user_logged_in returning nothing on custom page
  81. Customize Buddypress adminbar [closed]
  82. Help with accessing wp-admin page and resolving error messages
  83. Prevent Buddypress Rewrite Rules on Non-Buddypress pages/posts
  84. Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
  85. Can’t log in to WordPress wp-admin after adding code to functions.php
  86. Check if user had autologin & if so, logout
  87. Admin Panel 404 Error after login
  88. copy fields value to another field
  89. PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
  90. How to block specific user id in custom login form?
  91. Log out without confirmation request (nonce)
  92. Having trouble creating two shortcodes, one for logged in user and one for visitors
  93. Call WP Rest-Api to GET /users/me returned NOTHING in console
  94. Restrict wordpress access to logged users only
  95. Link to index.php from home.php?
  96. Infinite loop when logging out using custom login form
  97. how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
  98. Issues adding Recaptcha v3 to WordPress Registration
  99. Display specific page if user signed in
  100. Change Login or Logout text based on status
Categories PHP Tags buddypress, homepage, login, php
Wp custom post custom capability not working together
Recommended LogParser queries for IIS monitoring?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress