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

how to protect wordpress website

In the header.php of your theme you can add the following code @ the beginning of the php code

if ( is_user_logged_in() ) {
  header( 'Location: /' );
} else {
  header( 'Location: /wp-login.php' );
}

If the user is not logged it will be redirected to the login form else it will be redirected to the /home page or tha page u want.

Related Posts:

  1. Upgrade 4.5.2 to 4.5.3 deleting row in wp_options table
  2. ‘Global’ settings page for multisite plugin
  3. How to add field for new site-wide option on Network Settings screen?
  4. Contact form 7 select box different value-text than content-text in option [closed]
  5. Modifying a JS file with data from plugin settings
  6. Correct way to serialize the data of options table?
  7. Login with OpenID, similar to Stack Exchange sites?
  8. How can I make an Ajax login form work with FORCE_SSL_ADMIN enabled?
  9. Where should I use get_option in a plugin
  10. Inherit plugin settings to new site in Multisite
  11. How to tell if plugin has been network activated
  12. Is there a hook attached to general settings save?
  13. Change success message in plugin Theme my login
  14. How to get Login Error messages on a custom template
  15. How to find out if option exists but is empty?
  16. How should I use register_setting, add_settings_section, & add_settings_field in my plugin’s options page?
  17. Custom plugin settings: clicking “save changes” does not display success message
  18. How can a Firebase user registration and login be integrated into a WordPress site?
  19. How to get user-meta from Social Login registered users?
  20. Duplicate settings of master blog to slave blogs in WP multi-site installation
  21. Auto login using Active Directory and Windows Authentication
  22. Environment Specific Options Token
  23. How do I extract the Alt Text from an image attachment upload via the WordPress Options Framework Plugin?
  24. Which hook should be used to validate custom form fields on the login form?
  25. Network-Wide Plugin Settings Management
  26. How can I make content disappear when a user logs in?
  27. How to create a Page alias in WordPress
  28. How to create custom LOGIN and REGISTRATION forms?
  29. Tracking last login and last visit
  30. How to fetch serialized data from wordpress options
  31. login to wordpress with Get variables instead of Post
  32. Add custom meta box on Post page
  33. Some Plugin Settings Are Kept After Removal and Reinstall of the Plugin
  34. Changing widget options via the functions.php when there are no hooks
  35. While Using Static Pages, How Can I Get /blog into the URL of Each Post?
  36. Prevent Brute Force Attack
  37. Login with email (WP Modal Login)
  38. Check if the front end user is log in or not
  39. Get all options saved by another plugin
  40. wordpress custom login successful redirect hook
  41. How to create a word press user with hashedpassword
  42. WordPress with CAS+LDAP and standard WP accounts
  43. Is it ok to call get_option without hooks?
  44. Enable/Disable WP options programmatically
  45. Custom options page checkbox will not save, despite working with text
  46. Settings API – input always updates over validation
  47. add function to saving change on Options Pages
  48. get_option return incorrect values
  49. AJAX login without a plugin does not work. when add a action to function.php
  50. Option page not updating multiple records in settings api
  51. get_option returning old value for non-admin users
  52. Plugins effecting layout & login
  53. Add a checkbox in plugin options page and make it actually work
  54. Redirect default login page to a custom page [duplicate]
  55. Create Array from data in the OPTIONS table
  56. wp-admin will not redirect to wp-login.php
  57. Is saving multiple options or saving multiple items in one option better?
  58. Error when renaming option
  59. Validating values using Settings API?
  60. Adding google authenticator and use only email address of user
  61. Saving an array to get_options
  62. get Options value in “external” page
  63. Adding a Filter to Sidbar Login Plugin to Change Login Button Lable
  64. First argument is expected to be a valid callback for cp_admin_init and _canonical_charset
  65. ‘all’ hook and get_option issue
  66. How to find an option in the database?
  67. homepage olderposts link showing page not found
  68. Building a simple “settings” plugin to change textstrings on the home page
  69. WordPress ReAuth =1 Loop with wpCAS
  70. WP e-commerce sales-view
  71. My first plugin doesn’t save the data in options
  72. HTTP Error 403 When Trying to Login
  73. Advice on setting up private site
  74. Checking url from plugin [duplicate]
  75. How to programmatically detect how many posts are displayed per page?
  76. What plugin(s) are best for this User registration task? [closed]
  77. Trouble Removing Plugin [closed]
  78. Change All Login/Signup Links in Plugin
  79. How do I to override login redirect on specific pages?
  80. plugin for different writers [closed]
  81. selecting options from another form
  82. How to resolve these findings from security audit
  83. ERROR: Cookies are blocked due to unexpected output – no access to FTP
  84. How to Find WordPress site has backdoor login Codes
  85. How to create a custom wordpress plugin for a specific functionality?
  86. How to access values from your own settings page in javascript?
  87. Neither update_option nor delete_option fires in deactivation hook
  88. WordPress Homepage Login
  89. I cannot login after installing the wp-login timeout setting plugin
  90. wp_options Table keeps growing
  91. move setting data from wordpress api to codestar freamwork
  92. Multiple plugins settings of same developer into ONE settings page linked together
  93. When to store store plugin options as a single database record?
  94. How to fix a Wordfence scan that doesn’t finish?
  95. Issue: Unable to Access WordPress Admin and Database Errors
  96. Secure way to add JS Script to WordPress filesystem
  97. Custom Login and Password Reset for BuddyPress Website
  98. Is there a plugin or resource for custom implementation for OAUTH and regular user login?
  99. How to create WordPress login for different users, with different roles?
  100. Lost Password of my site, how to reset wordpress password?
Categories plugins Tags login, options, plugins
Add custom content to nonexistent page
Can figure out how to get wordpress to go .com not .com/directory

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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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