Plugin Author
cusmin
(@cusmin)
Hi! Thanks for your message. Basically, the capability feature in AGCA is used only for deciding whether the customizations will be applied to a particular user or not.
Here is a piece of code that you may use to restrict access to AGCA for all of your users, except for yourself. Please change the username of your admin, it’s set “admin” as a default.
function agca_access_only_admin(){
if(is_admin()){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
//////////////////////////////////
if($user->data->user_login != $accessAllowedOnlyTo){
wp_die( 'You are not authorized to see this page.' );
}
}
}
}
add_action('current_screen', 'agca_access_only_admin');
You can add this code to your theme’s functions.php
-
This reply was modified 7 years, 4 months ago by
cusmin.
Sorry but this doesn’t work. I am creating a new code snippet with this and the function line has an error “this.read_variable(…) is undefined”
Can you check the code please?
Plugin Author
cusmin
(@cusmin)
Can you please provide the code that you’re trying to use? Thanks.
Your code.
function agca_access_only_admin(){
if(is_admin()){
$screen = get_current_screen();
if($screen->id === 'tools_page_ag-custom-admin/plugin'){
$user = wp_get_current_user();
//Update this ////////////////////
$accessAllowedOnlyTo = 'admin';
//////////////////////////////////
if($user->data->user_login != $accessAllowedOnlyTo){
wp_die( 'You are not authorized to see this page.' );
}
}
}
}
add_action('current_screen', 'agca_access_only_admin');
Plugin Author
cusmin
(@cusmin)
I’m sorry but the error does not seem to be linked to this code. Could you provide more information, screenshots or stack trace? Thanks