Support » Plugin: Absolutely Glamorous Custom Admin » AGCA capability

  • I don’t understand how to add the AGCA capability to one user who I wish to set as the AGCA admin as opposed to other admins. I can see the option to “exclude agca admin from customisations” and how to set what that capability is but afaics the facility to single out one admin user as the agca admin requires more functionality.

    So I installed User Role Editor and using edit capabilities for an individual user wouldn’t allow me to remove one. So I created a new role an checked all capabilities except edit-dashboard (accepting the default suggested by AGCA) but that now only shows Dashboard. Perhaps User Role editor clashes with AGCA?
    I think this is a problem with URE. Is there another way to do this?

    Either I am missing something or you have given us a functionality without properly implementing it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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 1 year, 9 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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘AGCA capability’ is closed to new replies.