Get current admin user || Set custom cke settings for user role


I’m trying to get the current admin user in my view to set custom CKE settings if the user is not an admin.

I found several other projects that use the following:

$currentUser = \Pimcore\Tool\Admin::getCurrentUser();

But for me this is always null. Therefor my question is:
How do I get the current admin user in a view?

Or is there a smarter way to set custom cke settings to a certain user role?

Thanks a lot!

1 Like


I am attempting to do the same thing; to find out whether the currently logged administration user has admin rights or not, like so:


But this always returns null in my DefaultController (from the AppBundle).

I suspect that happens because the structures containing this information are somehow separated, i.e. the information about the backend user is not available from frontend.

What I need this for: I want to display a custom backend menu button (to reindex ElasticSearch) and use a method in the DefaultController that returns bool – whether to display the button or not – via an AJAX request made from backend.js extension file.

Any way of solving this? Thanks!


I just found the way to get the current user from MyAppBundle controllers.
You need setup first the security.yml and you can try in you controller $user = $this->getUser();



    # admin form login
        anonymous: ~
        pattern: ^/the_bundle_name/admin
        # admin firewall is stateless as we open the admin
        # session on demand for non-blocking parallel requests
        stateless: true
        provider: pimcore_admin
            entry_point: Pimcore\Bundle\AdminBundle\Security\Guard\AdminAuthenticator
                - Pimcore\Bundle\AdminBundle\Security\Guard\AdminAuthenticator

1 Like

Inside a view i found the following solution to get the actual backend user

$user = Admin::getCurrentUser();
if ($user == null) {
 $user = \Pimcore\Tool\Session::getReadonly()->get("user");