With a some digging and learning, I managed to combine various help and create these 2 functions…
// MAINTAINANCE MODE
function site_maintenance() {
if ( current_user_can('media') || current_user_can('genpo') ) {
$logout_url = wp_login_url().'?mode=maintainance';
wp_logout();
wp_redirect( $logout_url, 302 );
}
}
add_action('get_header', 'site_maintenance');
// CUSTOM LOGIN MESSAGES
function my_login_message() {
if( $_GET['mode'] == 'maintainance' ){
$message="<p class="message"><b>Site undergoing maintainance.</b></p>";
return $message;
}
}
add_filter('login_message', 'my_login_message');
Related Posts:
- wp_update_user not updating
- Is WordPress’ is_user_logged_in() secure?
- how to add custom user capabilities using add_user_meta or something else?
- Is there a way to set the user Role based on email domain
- pre_get_posts Remove posts based on meta value with ‘post__not_in’
- What is the difference between “create_users” and “add_users” capabilities?
- Access on specific pages in wordpress for a specific user
- How to ‘unpublish’ or ‘hide’ posts when user role changes?
- Hide Specific User Page
- Let new user role to ‘edit_others_posts’ of other user role, not of its own type
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- How do I remove the Other Roles field (from User Role Editor plugin) in wp-admin/user-new.php
- How to redirect specific post type with user role
- wordpress editor role remove all but ‘menus’ in appearance menu
- Parent User and Child User – relate users
- How to create user specific pages (not user role!)?
- Assigning certain authors to specific editors
- Restrict Access in Admin Panel
- Limit a user to have access to only specified pages?
- Plugin creation – how to add user rights?
- User restricted only show posts assigned to current user
- Restrict custom post content to specific user
- Hide front-end from every logged out user and redirect them to the default login page
- How to restrict an admin page, if the user is not superadmin?
- Need to block user role from accessing bbPress all together
- How to create a front facing user sign up, log in and profile pages like FoodGawker.Com [closed]
- Infinite redirects at front end if logged in user is not an Admin (Toolset Access)
- Is there a way to allow users with “Subscriber” user role to access media library in backend and frontend
- How to make WP page accessile only to specific user roles
- grant multiple roles access to specific admin menu item
- Check what capabilitie(s) an action requires
- Is it possible to restrict a specific user to edit a specific custom post.
- New folder and file permissions are not correct
- How to change user role setting in members plugin so that user can only edit his own post?
- How to get role of user
- How do I programmatically set default role for new users?
- How to get all capabilities of an existing user role
- How to update role capabilities
- Code needed to only show users own posts in a multi-user account
- Restrict Author to pick from media library, but not upload media
- Remove Ability for Administrators to Delete Administrators
- Order users by custom user meta
- List total number of users that are authors
- Auto Delete Users (auto_delete_users)
- New Roles and Capabilities in WordPress
- Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php
- WordPress Super Admin
- How are roles stored in the database?
- Can’t manage to make translate_user_role() work
- how to assign more permission to wordpress author
- Limit users by custom taxonomy and user roles
- Managing Users and Creating Groups [closed]
- Customizer – Allow user editor to change website title and tagline
- Query users which have same dynamically generated roles as the current user
- change role of wordpress users when they edit profile
- How to restrict CPT post’s fronted view only for specific user roles?
- Change post status based on user role
- Display User Role Next To Comment
- Allow an editor to change the author
- New user is assigned 2 roles: customer and superadmin
- How to give remove role editing permission from user
- How can I allow an User to publish only 5 posts per month?
- How to have kind of a technical writer role in wp website
- Where are $current_user->allcaps set?
- How to make the Newsletter plugin visible to users with author privileges?
- WP welcome email depending on user role
- Purpose of Adding Capability to Role But Not Grant?
- bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile
- Updater user with multiple roles
- Custom user types getting html sanitized in posts
- Hiding custom theme functionality using capabilities
- Building Forums with Custom Post Types
- Use PHP code to create custom user roles. Call it once?
- custom plugin not visible to some user roles
- What Capability is required to let a role RUN code in Edit Theme?
- Can I Create a Second Admin Level User Role?
- remove_cap nothing changes
- Retrieve user roles but exclude default roles
- Disabled delete_others_posts if post is from admin
- How to hide Add new Term area for taxonomy terms for specific role (Client)
- show the author’s role along with the name in the single.php
- How to create different views for different user roles?
- How to Enable registration email for a custom user role?
- Custom User Role: Can Edit Own Page, Cannot Create New
- How can I add the ability for a user to add/edit administrators?
- Allow signed in users (subscribers) to see their drafts
- How to sync user database with “user role editor” plugin enabled
- add user role selection to registration form [duplicate]
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- Grant access to admin menu?
- I want this code to work only for Authors AND Contributors
- Disable Woocommerce checkout based on user role [closed]
- Remove_role not working, gives “Call to undefined method stdClass::remove_role()”
- Adding a new role with administrator’s capabilities
- Front-end ajax problem all users and guests getting a 302 redirect when accessing wp-admin/admin-ajax.php
- How to assign a custom gender to a user role?
- assign roles to users in custom drop down in signup form
- Hide block of HTML if the users role is a certain role
- How might I enable a user to view Draft pages from a different Author, without the ability to edit?
- Display users by role