In your theme’s functions.php:
function hide_the_dashboard()
{
global $current_user;
// is there a user ?
if ( is_array( $current_user->roles ) ) {
// substitute your role(s):
if ( in_array( 'custom_role', $current_user->roles ) ) {
// hide the dashboard:
remove_menu_page( 'index.php' );
}
}
}
add_action( 'admin_menu', 'hide_the_dashboard' );
function your_login_redirect( $redirect_to, $request, $user )
{
// is there a user ?
if ( is_array( $user->roles ) ) {
// substitute your role(s):
if ( in_array( 'custom_role', $user->roles ) ) {
// pick where to redirect to, in the example: Posts page
return admin_url( 'edit.php' );
} else {
return admin_url();
}
}
}
add_filter( 'login_redirect', 'your_login_redirect', 10, 3 );
Related Posts:
- Add screen options to custom admin pages
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Send user activation email when programmatically creating user
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- How to Change the Entire WordPress Admin panel Look and Feel?
- Dashboard like meta boxes in my plugin – how to save their position and open/closed state?
- How to Structure a New Role/Capability Scheme?
- How to add more than 1 user role to sub-menu pages
- How to allow Unfiltered HTML in a wordpress multisite install
- Rearranging Dashboard meta boxes with use of plugin/functions.php
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- How to not let a user with a new role edit users that have administrator role?
- Execute plugin for specific user role(s) only
- query users by role
- How to create a Tools menu on the Network Admin dashboard from a plugin
- Hide plugin dashboard menu item for specific roles
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- get_posts() not working when accessing with a custom user role
- Limit role to one plugin [duplicate]
- Example Dashboard Widget, Cancel not working
- Dashboard – get status and position of metaboxes and pass them to ajax method
- Logout users upon login, based on caps/role?
- “dashboard”-named PHP file doesn’t get included
- Set different custom menu items for different user roles
- Prevent third party plugin’s admin page access based on user type
- wp_dropdown_roles() to replace option value = code
- Avoid updating post when sending POST or GET request to post.php
- Hide custom post type by user roles
- Check user’s role and store in variable
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- How can I change my assigned user role in WordPress 3.5.1?
- How to determine which capability to use?
- Custom Icon for Plugin
- How to show the posts listing on dashboard or custom page in admin panel?
- Allow contributor user role to perform copy operation PHP
- Enable a role named ‘backend_user’ to access my plugin pages
- Quick Draft widget (dashboard.php) using custom post_type
- Add custom parameter for custom user role
- Buddy Press restrict the capability to edit users
- How I can give access to my custom plugin for editor roles user?
- Remove all capabilities in separate method fails versus included in method
- Publish, Save Draft and Preview buttons do not work after being moved with jQuery
- Remove from a div by class name from post page if post author role is not administrator
- Adding admin for specific users
- What is more secure checking capabilities of user or checking role of user in WordPress plugin development
- New Users are saved with no role selected
- WordPress User Management Departmental Managers
- Tracing dashboard publish settings from input form in WordPress
- Create wordpress dashboard metabox which spans all columns
- Remove default wordpress roles
- How can I add a custom button to the post editor?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- Is it possible to add Custom Dashboard Widgets to Custom Admin Menu Page?
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Settings API with arrays example
- How to get the path to the current theme?
- How to make a plugin require another plugin?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- What’s the difference between term_id and term_taxonomy_id
- Should I use wpdb prepare?
- Why does WordPress use outdated jQuery v1.12.4?
- Post meta vs separate database tables
- Is there any plugin development framework
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- How do I create a custom role capability?
- How do I add CSS options to my plugin without using inline styles?
- How do i best handle custom plugin page actions?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Possible to hide Custom Post Type UI/Menu from specific User Roles?
- Automatically determine minimum WordPress version required for a plugin?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- How many times will this code run? (or, how rich is grandma?)
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- How to include a file using get_template_part() in a plugin?
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is it mandatory to use $wpdb->prefix in custom tables
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- What should I use instead of WP_CONTENT_DIR and WP_PLUGIN_DIR?
- How to enqueue JavaScripts in a plugin