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
- Send user activation email when programmatically creating user
- Export data as CSV in back end with proper HTTP headers
- Completely remove WP_Admin_Bar for specific user roles
- Change default admin page for specific role(s)
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- API to trigger prompt on leaving page
- How to Change the Entire WordPress Admin panel Look and Feel?
- Show message on wordpress admin dashboard
- Hook the Keydown Event in the TinyMCE Post Editor
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- how to use thickbox in admin?
- How do you create a custom edit.php / edit pages page
- Cancel post save
- Add a jQuery function to admin pages
- Is it save to require plugin.php early to be able to use get_plugin_data() earlier?
- WP Cron doesn’t save or in post body
- 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
- Problems with removing admin bar
- How to allow Unfiltered HTML in a wordpress multisite install
- Check if I am in the Admin Panel (wp-admin)?
- 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?
- How to not let a user with a new role edit users that have administrator role?
- Execute plugin for specific user role(s) only
- How to redirect to action on custom page within admin section
- WP AJAX is not working, always returns 0
- Catching Form Submission in WordPress Admin Panel
- Redirect in WordPress plugin
- How to add custom view links to wp-admin/post.php?
- 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?
- How do I duplicate a single post, with all its properties, and save it as a different post?
- 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
- check_admin_referer()
- 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
- Enable a role named ‘backend_user’ to access my plugin pages
- I cant add is_admin control to plugin
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Add custom parameter for custom user role
- Buddy Press restrict the capability to edit users
- Change Label of custom post type
- Stop unauthorised file access
- How to enable or disable check boxes in custom post type
- Redirect with message after admin_post.php
- How I can give access to my custom plugin for editor roles user?
- Remove all capabilities in separate method fails versus included in method
- 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
- 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
- Plugin dev: How to multiply instances of a plugin in the same metabox?
- WordPress User Management Departmental Managers
- How to add conent (text) to Add New pages form of admin in WordPress
- Issue with iframe in TinyMCE
- Forcing ALL plugin Admin menus into a separate menu
- Post data in wp-admin to external database
- admin page passing $_POST variables to itself
- WordPress multiple user roles accessing on their information on one site?
- modify buddpress adminbar only in admin pages
- Loading jQuery library from WordPress admin
- How to change the headline title for an admin page in a plugin?
- Remove default wordpress roles
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- How to prepend a header section to all pages related to my WordPress Plugin
- Update Cache on Save Instead of Clearing It?
- Create child of child custom page in wp-admin
- Load specific CSS file
- How to use native wordpress translation domain inside a custom plugin?
- Select a Text for CSS
- WordPress – Filter users list count
- Customize Message