Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1282848

    i thought i could manage it this way – but it does not work
    :

    function builder_set_debug(){
    	if(is_admin()){ 
    	  return 'debug';
    	}
    }
    add_action('avia_builder_mode', 'builder_set_debug');

    i want the additional info only for admin users – if even a redacteur is logged in – these extra fields should not be present.

    #1283461

    Hey Guenter,

    Thank you for the inquiry.

    You may need to check for the user capability using the current_user_can function.

    // https://developer.wordpress.org/reference/functions/current_user_can/

    For admin, try to check if the user can install plugins or themes.

    // https://wordpress.org/support/article/roles-and-capabilities/

    Best regards,
    Ismael

    #1283515

    Thanks – That works:

    $user = wp_get_current_user();
    $allowed_roles = array( 'administrator' );
    	if ( array_intersect( $allowed_roles, $user->roles ) ) {
    	   add_action('avia_builder_mode', 'builder_set_debug');
    			function builder_set_debug(){
    		return 'debug';
    	}
    }
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.