This can be done as concisely as follows (in your theme functions.php
or a plugin):
function wpse_231970_lockdown() {
if ( ! is_user_logged_in() ) {
global $wp;
/**
* Redirect to login page with redirect back to current request.
*/
wp_redirect( wp_login_url( $wp->request ) );
exit;
}
}
add_action( 'template_redirect', 'wpse_231970_lockdown' );
Related Posts:
- How to tell if a plugin is multisite compatible?
- Get plugin directory from a theme
- How to force WordPress to temporarily switch locale (using qTranslate)? [closed]
- GPL and plugins
- Redirection Plugin: Redirect all URLs with a regular expression
- How to un-attach rich text editor from named textarea elements
- Article source link for posts
- WordPress media upload limit?
- Post source link plugin – small modification
- How to add users roles dropdown in registration in wordpress
- Send Data to WordPress from kiosk
- how to not show plugin in admin area
- Getting User email on logout. wp_logout
- delay function on publish?
- How to get custom field image url of specific size
- Getting “Fatal error: Call to undefined function wp_cache_get() in option.php” after updating a cache plugin [closed]
- Can a plugin add to header/footer/body content?
- Login with email (WP Modal Login)
- How do I remove the entire left nav bar in admin for certain level users?
- Getting a 404 when trying to load /wp-admin/plugin-install.php
- Get total number of comment of the posts written by an author
- How to Dequeue All WordPress Assets
- Output HTML only on individual post view
- Why plugin ajax response is -1?
- How to integrate blog status?
- Elementor\Scheme_Typography’ not found [closed]
- How do I add a custom sub menu menu under Woo-commerce marketing?
- Changed permalink structure. Need help with redirecting old posts
- Unique 4 digit number
- One of my plugins broke when I tried to update it, how do I safely uninstall it?
- WooCommerce Checkout Error [closed]
- How can I change a plugin’s URL?
- LinkedIn Social Wall | Is there a plug-in (Free / Paid) to display a LinkedIn feed in a social wall (not just a feed)?
- jquery not calling php function
- WordPress change Language not working
- Advanced AJAX Page Loader ignores other JS code
- update_user_meta() misfires sometimes
- Migrating to WordPress Recipe Plugin and Some SQL Issues
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- wp_enqueue_script registers script but does not create html tag
- Multiple domains issue
- WordPress JS- Visual Composer
- WordPress plugin creating database in localhost but not on real host
- Does a blank plugin come with any overhead?
- Plugins fail to update: Download failed. A valid URL was not provided
- What is the right way to show reusable content
- URLs Added to ACF Repeater Field are not working
- Import Instagram post to WordPress blog post
- Set post tags using tag ID
- How to allow Contributors to publish articles after approval
- Making my plugin create a page?
- Not One ‘Contact Form Plugin’ will send email // Work
- How to generate an all in one WordPress New content, plugin and theme update report on a website? [closed]
- PHP Warning: Declaration of aec_contributor_list::form() should be compatible with WP_Widget::form($instance)
- Plugin translation not working on WordPress.org
- Built a second plugin but it overwrote the first one
- CMB2 not working in my WordPress theme
- Display Category Name of Current Post in WP Job Manager
- WordPress unable to write files in the server
- How to get CPT category checkbox list and show post of selected(multiply) checkboxes via ajax?
- Preview with Custom Post Type Not Working
- Insert a Woocomerce product in specific product category
- Edit page header on a custom plugin
- How to disable tinyMCE button added by a plugin?
- Custom page in plugin visible in menu
- Disable WP Bakery plugin on specific page
- Error using wordpress functions inside a plugin class
- Preventing a missing or faulty plugin loaded inside of wp-settings from halting a script
- Get the link title attribute and send it google analytics as custom label via google tag manager using beehive pro for WordPress
- I have English words in Kurdish pages
- How can I add a custom Javascript snippet to display my feedback in footer?
- WordPress 5 boot-sequence / load-order
- How to solve Blocked a frame with origin from accessing a cross origin frame error in wordpress?
- WordPress panel is not loading after plugin activated with error: HTTP ERROR 500
- Can I add content before post content without using the_content filter
- Only allow a plugin to work on a specific page? (Prefer not to use a plugin)
- Adding link for logged in user? [closed]
- Paid Memberships Pro, Display User Limit
- Fatal Error Paid Memberships Pro require includes/localization.php [closed]
- How to add dynamic content to posts page, archive, taxonomies, search, author, etc?
- Images is not showing after migration
- Changes required to make new plugin from existing
- WordPress Development understanding core
- Input gets deleted/overwritten after changing to different Admin Menu
- Redirect loop when forwarding to mobile site
- Server Path Information
- Drop down menu location select widget
- Cannot Search | Featured | Popular | Newest | Favorites in wordpress working
- Using Iris Colorpicker on TinyMCE shortcodes page [duplicate]
- WP-Snap too slow (caused by WP_Query?)
- Most visited posts
- Need help finding the right plugin for a dynamic piece of content that appears multiple places
- Thumbnails and Lightbox
- Integrate Mailchimp to a Contact Form 7 contact form [closed]
- Applying a coupon to a single product in woocommerce [closed]
- Plugin installation works only with FTP – how to debug?
- Allow users to download media files directly from Amazon S3 (AWS plugin)
- Passing an input variable through a switch statement
- Private plugin updating – GitHub zip file changes the plugin directory (with release or branch name)
- WordPress custom block: Link saved in database not retrieved when editing post