Here is a little snipit of code that I used for my site while it was under construction
<?php
/* ROUGH METHOD OF DENY ACCESS */
$underconstruct = array(121, 46, 124, 97);
if(!is_user_logged_in() && !in_array(get_the_ID(), $underconstruct)) {
wp_redirect(get_permalink(121));
exit();
}
?>
I put this at the top of my header.php
.
the $underconstruct array is the page/post ids that all not logged in users can see. If they are not logged in and are not on one of the pages that they should be, they get redirected. If the user is logged in, then everything will proceed as normal.
Related Posts:
- Should I add sharing buttons using a plugin or directly in my theme files?
- Should I use RIPS tool to test my themes and plugins?
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- Between functions.php (theme), widgets, and plugins, which is loaded first?
- What security concerns should I have when setting FS_METHOD to “direct” in wp-config?
- What Are Security Best Practices for WordPress Plugins and Themes? [closed]
- Are WordPress Plugins essential?
- I found this in a plugin. What does it do? is it dangerous?
- What are the common security flaws I need to look for? [closed]
- Disabled plugins are they security holes – rumor or reality?
- What could a hacker do with my wp-config.php
- Is there any sort of theme dependency management?
- How to make plugin required in a wp theme without using php conditional statements when calling an individual function from that plugin?
- How Can I Securely Implement a Password-less Login Feature?
- How do I cleanly override a plugin’s CSS with a child theme?
- Security and .htaccess
- Is it possible to stop selected plugins from loading on certain template pages?
- Can I make plugins required?
- Why “Contact Form 7” doesn’t update PHPmailer library?
- Are there procedures to prevent malicious plugin updates?
- Add Plugins to WordPress Theme
- Secure WordPress paid plugin
- Hide wordpress plugins from list
- wp_enqueue_scripts not working in custom theme
- How to make media upload private? [duplicate]
- Does WordPress contain “default” anti-SQL injection code that responds with a 404 error?
- Is there a maintenance mode in WordPress core?
- What does a security risk in a plugin look like?
- What is the correct way for a theme to support plugin UIs?
- Automatically install wordpress plugin at theme activation
- When coding a WordPress theme, where does the theme (i.e. the presentation) end and the plugin (i.e. the functionality) begin?
- Adding a text domain to every __(), _e() and __n() gettext call without a plan to create own translations
- WordPress Capabilities: edit_user vs edit_users
- How to call “page specific menu items” in template [closed]
- Should we use plugins that aren’t available from the official WordPress site?
- Is it good practice to remove redundant plugins and themes?
- Create WooCommerce Product Category Programmatically
- How to check plugins for malicious code?
- How to properly secure my WordPress installation?
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- WordPress tips for speed and performance [closed]
- How to access options of Redux framework in front end
- Update Multiple Post Meta for the Same Post In One call?
- Function to activate WordPress theme inside a plugin
- Integrating plugins in themes
- Seeking clarification on page request life-cycle
- Why allow overriding crucial pluggable functions wp_verify_nonce and wp_create_nonce?
- Where should my plugin POST to?
- Which functions in theme or plugin load first
- Get info (url) from already enqueued styles
- How to hide fields from my user profiles
- How do I make my wordpress page more friendly for mobile viewers?
- Security error WP 4.0 + WP phpBB Bridge [closed]
- Should I install plugins to my WordPress installation from web sites having in URL “nulled” or, “null”?
- WordPress Enqueue Script Chaos (jQuery & Foundation.js)
- login to wordpress with Get variables instead of Post
- How to make my plugin theme-independent?
- Can plugins become obsolete?
- How to load a new template page according to a particular URL?
- Disabled plugins are security holes – rumor or reality?
- Why am I sometimes getting a 404 error when I try to update a page with Elementor?
- Check javascript file Proper way in functions.php
- Prevent Brute Force Attack
- Translate third party plugin and save translation files in custom theme
- Under which circumstances is the .maintenance file not deleted?
- Add custom buttons with custom actions in Edit Post screen in WordPress?
- Code in theme functions.php faster than with a plugin?
- Why users disable the WordPress update?
- How to Build a Movie Library in WordPress 3.x
- How many security plugins are too many? [closed]
- Will WordPress username displayed somewhere in the site?
- Upgrading WordPress 4.0 asks for FTP password
- How do I future proof my older WordPress theme?
- resize only height using wp_get_image_editor
- Autoload via composer in plugin interference
- Is revealing just the AUTH_KEY a security issue?
- How Restrict access to admin dashboard by specific static ip?
- Workflow and best practice for documentation [closed]
- Is there a quick way to inject i18n domain into theme/plugin files?
- When is it useful to use wp_verify_nonce
- register_theme_directory somehow “fails” when folder is outside of WP-Folder
- Protecting against malicious code in WordPress plugin updates
- Display future posts?
- Questions about brute force attacks on the admin username, coming from amazon IP addresses
- Why Better WP security plugin returns 418 I’m a Teapot “error”?
- WordPress language switcher
- How to expire all wordpress user passwords instantly?
- Having separate plugins and themes folder for multi-site setup
- Showing Co-Authors on post page
- How can I get full attachment url from wp_get_attachment_metadata?
- WP theme with Backbone
- Translating plugin inside the theme [closed]
- unzip a folder on specific location and delete the zip file
- Editing Theme to apply Co-Authors Plus
- gallery option is not available in media upload box in costum theme option page
- Why are some of my thumbnails not being generated?
- Why is the Settings API is not saving my array of options
- rms_unique_wp_mu_pl_fl_nm.php
- Built in audio player?
- Weird problems after recovery from security breach