Answer the question
In order to leave comments, you need to log in
How to organize access rights to Wordpress plugin?
I'm writing a plug-in "Add-in". I need to organize the access rights to the plugin settings page so that if there are not enough rights, this page will not even appear in the left menu of the admin panel. I have never specifically written permissions for plugins. Temporarily made a check of the user's rights with the output of messages for the user about an insufficient level of rights. But how do you remove the settings page from the list altogether?
Answer the question
In order to leave comments, you need to log in
The easiest way is to check the user's permissions in a function that adds a settings page to the menu:
function true_options() {
global $true_page;
if( current_user_can('manage_options') ){
add_options_page( 'Параметры', 'Параметры', 'manage_options', $true_page, 'true_option_page');
}
}
add_action('admin_menu', 'true_options');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question