Skip to content

Override locked users status pill color #10313

Closed Answered by brandonkelly
nstCactus asked this question in Ideas
Discussion options

You must be logged in to vote

You could register a custom data-locked attribute on user elements using a custom module:

use craft\elements\User;
use craft\events\RegisterElementHtmlAttributesEvent;
use yii\base\Event;

Event::on(
    User::class,
    User::EVENT_REGISTER_HTML_ATTRIBUTES,
    function(RegisterElementHtmlAttributesEvent $event) {
        /** @var User $user */
        $user = $event->sender;
        
        if ($user->locked) {
            $event->htmlAttributes['data-locked'] = '1';
        }
    }
);

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@nstCactus
Comment options

@nstCactus
Comment options

@brandonkelly
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants