This should do it. Place it in your theme’s functions.php
or a plugin.
function tst($a) {
if (!current_user_can('edit_posts')) {
wp_die('You are not allowed to view this page');
}
}
add_filter('template_redirect','tst');
You can still get to the login page like normal by going to “/wp-login.php” or “/wp-admin”.
Alternately, you could use wp_safe_redirect
or wp_redirect
instead of wp_die
to send people to a “Coming soon” page or something like that.
Related Posts:
- How to restrict a page [without plugin]
- How to restrict attachment download to a specific user?
- Restrict the user access in multi site for non-assigned blogs
- Restrict certain posts from being sent to the feed subscribers
- Hide everything on site for visitors except specific page IDs
- How to restrict logged user to view only certain pages?
- Limit post display to post authors and create an exception for specific pages
- How do we restrict a user to see a field in a post without registration,
- User restricted only show posts assigned to current user
- One Site as a part of Multisite to be hidden (Un-published) from Public?
- Restrict access to trash, only admin
- Hide front-end from every logged out user and redirect them to the default login page
- Restrict the list of parent pages to only those which are created by current user
- Hide posts of particular category for everyone except of particular user group or role
- How to restrict an admin page, if the user is not superadmin?
- How to restrict access to a single for users I’ve authorized? [closed]
- How prevent direct access to PDF file
- How restrict video to be open on direct url hit
- How can I restrict a custom WordPress role access to only a specific plugin?
- Disable Page if user not logged in
- Is there a way to create folders restricted to specific users to open?
- Learndash groups content protection with tags
- How can i restrict a page to certain user roles?
- How to show private pages based on a user’s role?
- How to use url formatter with integer
- Segregating content in a blog for 2 different readers
- Restrict directory listing to only logged in users
- Restrict content even to specific user
- Restrict access to custom post type and filter from every query
- Member Site – Always Sends Me Back To Login
- Hide page link in main menu from anonymous users
- How to give members access to their own protected page?
- I want to restrict a page for subscriber and contributor
- How to stop EU users from accessing my website?
- Multisite Login Access Restrictions
- Allow member to have access to custom post type only. Permission to only edit their own posts
- How do I create a custom role capability?
- How to enable suggested edits?
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- How to programatically change username (user_login)?
- How to check if user is in back end?
- simple solution for restricting access to (some) uploads/downloads
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How to restrict access to uploaded files?
- wp_update_user not updating
- Allowing users to edit only their page and nobody else’s
- Can an admin check passwords of registered users?
- Correct Post Count ( All | Published | Drafts | Pending | Trash ) for Custom Post Type when restricting to view own posts
- User redirect to destination URL after login
- HTTPS leads to Sorry, you are not allowed to access this page
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- Restrict admin access to certain pages for certain users
- How can I hide a category from Contributors in the edit/add new post screen?
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Hide Admin Menu for Specific User ID who has administrator Role
- How to get all capabilities of an existing user role
- Allowing an email as the username?
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- Limit access to posts/pages by user roles
- Allowing specific users to only add posts using certain custom taxomy terms
- Is WordPress’ is_user_logged_in() secure?
- Website Visible only to Registered users
- Check if specific username is logged in
- Create a USERNAME and PASSWORD protected WordPress page
- Loading posts associated only to the logged in user on recent posts page
- How to manually activate user in dashboard only by admin
- Does pre_get_posts affect REST API responses?
- Post list based on the user that is logged in
- REST API: How can I restrict a custom post type to only be accessible by authenticated users?
- Only allow administrators and editors to access wp-admin
- Theoretical Multi-Server WordPress Setup with Shared Users
- Show custom post type endpoint in REST API just if user has capability
- Restrict post edit/delete based on user ID and custom field
- Restrict users on multisite WordPress install
- How do you add a custom option to user data?
- Using JWT to authenticate a user with an external system?
- The ‘user_has_cap’ hook seems to take two page loads to trigger
- Basic auth WordPress REST API dilemma
- Allow anonymous user to access Themes Customizer
- How can I hide media library images from general users?
- How do I display a user specific content?
- Temporarily disable user role login and replace with message
- Access code/password only restricts page access, no user registration..?
- How can I limit functionality in one version of a plugin?
- How to show a category post to a specific registered user
- Add user capability and check against it
- how to add custom user capabilities using add_user_meta or something else?
- Hiding posts from non logged in users
- Copy a user from one WordPress site to another
- Restrict access to post if it is currently being edited
- Restrict acceess of a page in backend
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Moving wordpress from localhost to server throws admin panel access error?
- Restrict access and display for categories
- Only show category to certain user levels without plugin
- how to make author to write comment on only his own posts?
- if role is logged in then do something
- Remove Custom Post Type menu for non-administrator users.
- Add new media uploader at frontend for wp 3.5+