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
- What Are Security Best Practices for WordPress Plugins and Themes? [closed]
- Are WordPress Plugins essential?
- What are the common security flaws I need to look for? [closed]
- How do I cleanly override a plugin’s CSS with a child theme?
- Is it possible to stop selected plugins from loading on certain template pages?
- Secure WordPress paid plugin
- 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?
- 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
- Function to activate WordPress theme inside a plugin
- Seeking clarification on page request life-cycle
- Which functions in theme or plugin load first
- Get info (url) from already enqueued styles
- Why am I sometimes getting a 404 error when I try to update a page with Elementor?
- Why users disable the WordPress update?
- Will WordPress username displayed somewhere in the site?
- resize only height using wp_get_image_editor
- Is revealing just the AUTH_KEY a security issue?
- Why Better WP security plugin returns 418 I’m a Teapot “error”?
- WP theme with Backbone
- Translating plugin inside the theme [closed]
- Editing Theme to apply Co-Authors Plus
- Include Max mega menu Plugin into theme
- How to include plugin without activation?
- Custom Taxonomy Tag Search
- wordpress theme backend admin only
- Check if we’re viewing an event
- Menus, but not by theme location
- How To Clean The Malware Infected & Hacked WordPress Websites? [duplicate]
- How to get current post user id
- Events Made Easy Plugin – Duplicate Title Tags
- What is the correct way to update both WP/plugins/themes without breaking the site?
- Redux Framework has an embedded demo. Click here to activate the sample config file
- The problem with WordPress Importer
- how to give a user a role?
- Upgraded to latest version – 3.0.3 and Now I get a “sufficient permissions to access this page” error
- Display post lists in 2nd paragraph
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- How can I position ShareThis buttons manually when using the plug-in? [closed]
- Malware installation during plugin update?
- How to use get_template part in the plugin?
- Overriding Parent Theme… will cause plugins failure?
- I should enable automatic updates?
- How can I show a different theme for admin users? WP 3.8+
- How to show the number of website visitors in my theme
- How to write “alt” tag in image for wordpress code?
- Website show Google Ads when we have no Google Ads linked to our website
- Vulnerability Concern From the Plugin or From Not Updating the Plugin?
- Shortcode Attributes to Return different $_POST
- What form should the $query media query array have for an Elementor page builder function? [closed]
- is_rtl returns false while it should return true
- Include Minit plugin in theme [closed]
- Chrome Dev Tools console says every page in my blog has link to http://maps.google.com [closed]
- Set up functions to be overridden without using function_exists() by short-circuiting them?
- WordPress custom post type image in RSS
- Inserting Plugins Into Blank Space of Externally Designed WordPress Theme
- Regarding plugin security
- How do I determine if the user who registered is not spam?
- display unique post per category
- Polldaddy doesn’t show up on own theme
- How to add an admin alert for missing plugins
- Is there a way to insert multiple images into a post at the same time without using a gallery?
- Is there a way to keep youtube videos from displaying on home page, and display only on single posts?
- Yoast SEO Plug In and my Theme duplicating code. Need some feedback on what to do? [closed]
- Janrain/Simple Modal under Redirected Domain
- Warning: Attempt to read property “ID” on null in C:\xampp\htdocs\Nnamdi1\wp-content\plugins\elementor\core\base\document.php on line 250 [closed]
- require_once not working in plugin wordpress
- How can I disable new plugin and theme install, but allow updates?
- Validating ajax search
- Unpublished Pages Failing To Appear On Custom Path
- WordPress disable direct access of files in WordPress installation path
- How to Add call button on a featured image in a wpsite? check the slap king image, there are two buttons on the featured image
- WordPress hierarchy clarification, does post_type_archive take precedence over taxonomy-term archive?
- How can I find related learndash course id from woocommerce product object?
- Remove action added in plugin class from theme
- Can you develop themes and plugins while using the hosting services BlueHost? [closed]
- Contact form function should be in functions.php or in a plugin file?
- how to add custom css at top above all css file for specific url
- Coming soon pages with rest of site in maintenance mode
- How to add wordpress plugins in along with my standalone theme
- Being hacked. Is there a list of WordPress security holes I can check against?
- Unwanted Links and Spam WordPress Pages and Posts
- How can I add different menus (different style menu) on each page?
- File permissions for wp-minify plugin
- Site is setup statically – how to make it content managable?
- How can I make a website with dynamic features with wordpress?
- What is the recommended way to be notified of security updates to my plugins? [closed]
- Javascript as Jquery Function Call?
- Detect if you’re in the “Frontend Editor” mode in Visual Composer WordPress [closed]
- Can anyone tell some online tuts for plugin development for beginner? [closed]
- How to escape html code?
- Is website for online game guides doable in WordPress? [closed]
- WordPress User Registration/ Sign Up -> Able to take Paid Certification Courses & keep track of Completed Certificates
- Block Root REST API Route using custom &/or iThemes