1

Am using a third party plugin(eg. ABC Plugin). And their code doesn't have any hooks or filters. And they don't provide customization based on our requirements.

So if I modify the plugin code, I would have to duplicate the changes each time when an update is available for that plugin.

Hence I decided to create a plugin, that will work along with the other plugin, and make the necessary modifications.

Right now, I want to limit the access to a specific url of the plugin page (in admin panel), only to a specific user type. And the url is like https://mywebsite.com/wp-admin/admin.php?page=abcplugin&route_name=customers__index

Am thinking to use the admin_init hook to check whether the current requested url is the above, by simply doing if( $_GET['page']=='abcplugin') && $_GET['route_name']=='customers__index')

But am not sure how to show the You do not have permission to access this page error message. Any inputs?

1 Answer 1

0

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/

1
  • Thank you. That helped.
    – Vpp Man
    Dec 18, 2019 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.