Answer the question
In order to leave comments, you need to log in
How to create a user for only one plugin?
I am writing a plugin where a user is created, how can I make this user have access only to this plugin?
Answer the question
In order to leave comments, you need to log in
You can create an option in the plugin with a nickname or user id and check it for a match.
function plugin_user_option_settings() {
global $plugin_option_page; // Страница опций
/* Cекция пользователей */
add_settings_section( 'plugin_user_section', 'Пользователи плагина', '', $plugin_option_page );
$plugin_users_field_params = array(
'type' => 'text', //может быть чекбоксы, селекты и т.д., взависимости от ТЗ
'id' => 'plugin_users',
'desc' => 'Пользователи с допуском к UI плагина. Укажите ID, или Ник',
'label_for' => 'Пользователи с допуском',
);
add_settings_field( 'plugin_user_section_', 'Пользователи системы', 'plugin_user_option_settings', $plugin_option_page, 'plugin_user_section', $plugin_users_field_params );
}
add_action( 'admin_init', 'now_open_option_settings' );
// Код написан в качестве примера. Нужны правки и доработки
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question