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?
- Update Option Stored in Multi-Dimensional Array
- check if Gutenberg is currently in use
- WordPress Plugin Development – Headers Already Sent Message
- $wpdb->insert_id
- Remove profile picture option (and other things) from profile.php (in admin)
- Does WP fire delete_post when trashed posts are automatically deleted?
- How to list events by category and month with plugin Event Organiser?
- Dropdown list of pages to get page id to store in plugin options
- Create a new page in a plugin
- Find source of notice / warning / errors efficiently
- Use wp_set_post_terms() instead of wp_insert_post()
- Create a free scripts and styles template within a plugin
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- How to enqueue style in WordPress plugin from theme files?
- Bootstrap version conflict 3 with 4 for wordpress theme and plugin [closed]
- pre_get_post alter current post id
- Problems with cron
- Remove Default Blogroll Links via Plugin script
- Filter posts in pre_get_posts order by meta value date (desc or asc)
- How to display the category id along with category name on categories list?
- Serial Number from custom table not appear in woocommerce_email_before_order_table action
- How to replace the existing metatag using the backend to insure a thumbnail image gets fetched when we share on social media?
- get_comment_meta() for a filter hook in a plugin
- form does not generate $_POST request
- Callback function quicktags that uses variable in start tag
- Font Awesome stopped showing icons, shows &# text instead [closed]
- WordPress Plugin Tool Tip Helpers
- How can I add the Post ID to Class Name in Jquery?
- plugin will not offer update even though a new version is available
- Enqueue Script in custom plugin before other
- How to remove a class [closed]
- Find Any Theme’s page.php File
- WP Job Manager – Show recent jobs as cards
- How will i add an option under customizer the event calendar section?
- Return custom product in ajax call loop
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Admin Menu for New Post
- Elementor Top-Bar
- Is using upgrader_process_complete the correct way to perform plugin updates?
- Load images from CDN and custom features to “Add Media” dialogue
- Saving metabox updates causing fatal error
- Calling get_header() with installed FSE theme
- Reinitiate Gutenburg’s blocks using javascript
- Generating Multiple Divi Pages from Database
- Is it smart to require_once wp-admin/includes/plugin.php when you need only one function from it
- multiple record insert creating many duplicate records