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
- How to check if user is in back end?
- How to get all capabilities of an existing user role
- How to manually activate user in dashboard only by admin
- How can I limit functionality in one version of a plugin?
- how to add custom user capabilities using add_user_meta or something else?
- Restrict acceess of a page in backend
- 403 Forbidden – You don’t have permission to access /wp-admin/admin-ajax.php on this server
- Allow Users Access to Custom Post Type Only
- How can I allow access to two user accounts using one login?
- how to assign more permission to wordpress author
- authenticate user without password from email activation link [duplicate]
- Limit users by custom taxonomy and user roles
- Protect custom php file with login
- Edit Post VS Custom Form
- Managing Users and Creating Groups [closed]
- Restrict other Admins from using Editor in Admin Panel
- Upgrade Nightmare – No Posts, Permissions Issues and Can’t Create a new post
- admin_post action not usable if admin access denied to user
- How to restrict CPT post’s fronted view only for specific user roles?
- How can I allow users to make groupings of posts
- Multisite registration problem [closed]
- Protect sequence of pages with same password for each of two groups of users
- How can I restrict image upload dimensions for non-admin WordPress users?
- WordPress login problem
- How can I allow an User to publish only 5 posts per month?
- Assigning certain authors to specific editors
- Where are $current_user->allcaps set?
- Disable comments for a user? [closed]
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How to properly print a 404 error without redirecton? (i.e. keeping the current URL)
- How to allow registered users to submit the form only 5 times per day?
- Auto log in hook is requiring a page refresh
- Downloadable content only for subscribers?
- Make (custom) post type accessible only by custom query
- How to Find The Email of a WP Admin Account
- Using WP for user management
- redirect if shortcode exists
- Can I Create a Second Admin Level User Role?
- How can I lock specific posts (cpt’s) from editing by anyone other than ADMINS
- Give access of horizontal scroling plugin to user role editor
- force login loophole
- Simple Math Quiz or Captcha to hide whois query form
- Plugins that restrict access based on user group/roles
- Allowing WordPress.org/com accounts on a self-hosted install
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- Restrict access for wp-admin panel
- Plugin or ways to limit number of users logging in the website,
- How to add a “base” filter for all posts visible to visitors on the site?
- How can I fetch user registration age
- How to create different views for different user roles?
- Restrict user to terms in a custom taxonomy registered for both posts and users
- Custom User Role: Can Edit Own Page, Cannot Create New
- How to lock WordPress front-end with login and password?
- Restricted images only for logged user. (hidden url)
- Using a page-template to restrict access based on IP (Frontend)
- How to enable to the user send content and save as draft entry?
- Front end login and page restriction
- Allowing access to certain WordPress created pages or posts with htaccess / htpasswd
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- view and update form only for registered users
- Use WordPress engine for user registration and management
- How to make future posts visible to selected visitors without login
- How can visitors redirect wp-admin to the homepage?
- How to post data to a word press site in case of a mobile app
- You do not have permission to access this document on form submit