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:
- “Add Media” button in custom plugin
- Disabled plugins are they security holes – rumor or reality?
- How to implement WordPress plugin update that modifies the database?
- Create tabs inside Plugins Admin Page [closed]
- Looking for a Table of Contents (TOC) plugin for WordPress
- Writing test cases for a WordPress Plugin that has translations
- Can’t install new plugins because of the error “Could not create directory”
- Customize plugin update “new version is available” text
- Core framework/helpers for logging stuff?
- Disable Specific Widgets on Selected Pages of a WordPress Website?
- How to handel multiple checkbox field in the admin settings page with Settings API
- Are orders of magnitude used for “Active Installs”?
- To remove plugin notices for non-admin users
- Loading shortcode with ajax
- Files being generated in multiple directories supposedly by WordPress (advanced_settings.php and common_config.php)
- WordPress wp-json API – Custom Post Type returns 403
- Creating Custom Meta Boxes on Plugin Option Page
- An old plugin self-made stoped sending mail
- Translate wordpress plugin [closed]
- Nested shortcodes
- Is there a neater way to do this?
- How can I use RDFa with WordPress?
- How to add an attribute to the body tag with a plugin?
- plugings request url is the old url
- Authorization header malformed. [jwt_auth_bad_auth_header]
- Changing image size to full size in Gutenberg’s block gallery
- Unable to activate wordpress importer after installing it
- Trying to count the total number of paragraphs inside a blog article
- Saving Custom Post types and fields to a custom table
- How to Create a Custom Plugin Permalink
- Regex to Remove File Extension
- Inserting HTML tag with ACF into shortcode
- Loading jQuery UI in the head
- WordPress JSON API remove posts from a specific category
- How can I get automatically anchors for every h2-heading?
- How to delete page by deactivating plugin
- Trouble with plugin styles in admin area of WordPress
- How to edit content before post update
- Remove product-category slug plugin works with 1 subcategroy not with 2
- Install and activate plugins across 200 wordpress installations via SSH
- How can I add few css or js file into my plugin
- How to add single function for all WordPress hooks
- How to use get_template part in the plugin?
- How can I use get header from within my plugin?
- add_action into another add_action not working
- Free shipping for certain items only – or get local pickup as option if item is set to virtual
- Elementor Gallery issue [closed]
- How do I publish portfolio items with a future date?
- WordPress stats: OWA plugin overhead in the future
- What form should the $query media query array have for an Elementor page builder function? [closed]
- WooCommerce: Force coupon for existing/registered customers [closed]
- Using custom fields for image alt and title
- Code not working with post name Permalink Settings Help
- WordPress /users/me endpoint request forbidden
- Hook Scripts and Styles in WordPress
- Adding a theme option to the admin that lets me turn on/off a javascript file
- Echo out element to another page.
- Remove updates text on plugin or themes list page
- How to turn off automatic operation for Nivo Slider?
- Absolute paths in backend for plugins after moving wordpress
- Janrain/Simple Modal under Redirected Domain
- get wpforms ID value from ACF text field
- WP REST API GET Method Works But Not The POST Method
- WordPress Gutenberg custom block
- Working on a product group in wordpress, where user choose how many children, wife and husband
- How to set Google Analytics tracking code on WordPress plugin directory page?
- Show prices with tax Inclusive in Minicart widget
- Adding category base to url in custom post giving 404?
- Custom fields not showing up in the user info (PaidMembershipsPro)
- Main content of site not showing, but does show when logged in to wp-admin
- Problem with checked box on wp car manager plugin
- Tool to highlight text in WordPress page and provide additional text on hover
- Elementor contact form doesn’t work: “Oops! I cannot send this email!”
- Change the color of ACF Subtitle output background
- my hook or my function wont run in the cronjob
- How to block access to certain WordPress pages using a snippet
- Woocommerce list variations that are added already to cart in Single Product
- Upload profil picture to every member
- Passing ajax variable to more than one wordpress plugin function
- WordPress Theme Conflict With Plugin
- Why isn’t my plugin seeing other classes?
- Manually updating plugins via FTP or SCM
- using jquery serialize in ajax operation for plugin
- Saving custom form fields
- How do I to override login redirect on specific pages?
- wp_insert_post_data filter to set category
- Embedding BitBucket Code in Posting
- Do shortcodes affect page indexing by search engines?
- Unable to access WPadmin, website down
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- How can I display an attribute from each post inside foreach($latest_posts1 as $post )
- Wrong block appender button showing
- Check Plugins in Use by Mutli Site Network
- Plugin with Fatal error
- Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table
- Select posts from list and add them in a new list
- Plugin to transfer new/updated files from media library in “/wp-content/uploads/” between prod environment and preprod environment?
- Need to add custom cart item data
- Require registration to access a certain page