It’s done with wp_die().
Something along these lines:
if ( $no_user_access ) {
wp_die( 'You do not have permission to access this page' );
}
See: https://developer.wordpress.org/reference/functions/wp_die/
Related Posts:
- How can I add an image upload field directly to a custom write panel?
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How do i best handle custom plugin page actions?
- How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- what’s the meaning of the field wp_capabilities in table wp_usermeta
- Export data as CSV in back end with proper HTTP headers
- Change default admin page for specific role(s)
- Show message on wordpress admin dashboard
- Hook the Keydown Event in the TinyMCE Post Editor
- How do you create a custom edit.php / edit pages page
- Cancel post save
- Is it save to require plugin.php early to be able to use get_plugin_data() earlier?
- Create a clickable name in WP_List_Table for Plugin Admin
- How to Structure a New Role/Capability Scheme?
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- URLs of plugin resources?
- How to add more than 1 user role to sub-menu pages
- How to allow Unfiltered HTML in a wordpress multisite install
- How to add custom content under plugin row in WordPress admin plugin list?
- How to put placeholder text in the main post input area?
- How to restrict plugin’s sub-menu pages to admin/subscribers?
- How to load the plugin only when logged in?
- WP AJAX is not working, always returns 0
- query users by role
- Hide plugin dashboard menu item for specific roles
- How to run a external JavaScript file on wp-admin if admin, and other if normal user?
- add a class when login
- Add a panel to edit post
- Using the default wordpress uploader inside plugin
- Modify users.php page to create page/post on button clicked
- Any problem in using native jquery ajax style instead of using admin-ajax.php?
- maintaing consistent layout wordpress dashboard
- Replacing Scripts in Admin Load_Scripts
- get_posts() not working when accessing with a custom user role
- Problems with: manage_${post_type}_posts_columns
- On cliking add new post redirect user to a custom page first
- Set different custom menu items for different user roles
- Admin – Handle data before creating or updating a post, page or custom post
- Password field is empty when using wp_signon();
- How can I replace content in the WP Admin area before an admin page is rendered?
- Using ReactJS in the WordPress admin for plugin development
- template_redirect or admin-ajax.php?
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- How to load library scripts in admin from plugins in noConflict wrapper?
- Show error message after exception handled
- wp_dropdown_roles() to replace option value = code
- Issue with contextual help overwriting existing content
- Enqueue script globally
- Alternatives to DISALLOW_FILE_EDIT wp-config Constant? It Breaks Some Plugins
- How do I add a favicon that only shows during viewing of my plugin’s admin panel?
- Hide custom post type by user roles
- 400 Bad Request, in wordpress theme development, wp_ajax
- WordPress custom post type capabilities issue
- How to import the css in the plugin admin area?
- Creating multiple wp_editer() text fields in for loop — the text/visual switch only works for first editor
- Displaying “One Time” Notification in Plugins
- Admin Subpages without Menu entry
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- Data not insert and update through ajax and jQuery in admin page?
- Catching Form Submission in WordPress Admin Panel
- Is it possible to load the css just on my plugin admin page?
- AJAX button with success callback. (Titan Framework)
- jQuery UI tab does not work in the plugin page
- Disable Auto-Expanding Menu in WordPress Admin Menus
- Best practice for plugin: always detect admin-ajax call?
- How do I force a download in the admin area?
- Submit form to a different PHP file in the same plugin folder
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- How can I change my assigned user role in WordPress 3.5.1?
- Remove Permalink Meta Box not working?
- Remove Meta-boxes (Yoast SEO plugin) [duplicate]
- How to add text editor in plugin menu?
- How to determine which capability to use?
- Get cat parameter from admin-ajax
- How to make an admin plugin menu page go full screen?
- WordPress admin panel not working
- Allow contributor user role to perform copy operation PHP
- Add New Button in Admin Panel
- I cant add is_admin control to plugin
- Add custom parameter for custom user role
- Buddy Press restrict the capability to edit users
- Change Label of custom post type
- How to enable or disable check boxes in custom post type
- Redirect with message after admin_post.php
- Remove from a div by class name from post page if post author role is not administrator
- How to display properly exception or echo string after posting in plugin?
- Same header/footer in Admin, across all network sites in multisite
- Get (eventual) permalink from post within Edit Post in Admin panel
- Adding admin for specific users
- New Users are saved with no role selected
- WordPress User Management Departmental Managers
- How to add conent (text) to Add New pages form of admin in WordPress
- Forcing ALL plugin Admin menus into a separate menu
- Post data in wp-admin to external database
- WordPress multiple user roles accessing on their information on one site?
- Loading jQuery library from WordPress admin
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- How to use native wordpress translation domain inside a custom plugin?
- Customize Message