Restrict customise access to Block Plugin

Restrict customise access to Block Plugin

by Ken Burch -
Number of replies: 0

I think I have searched all the forums and not found an answer to this.

I have developed a block plugin for the user dashboard that uses capabilities to control behavior, such that it will look different for a Student and a Tutor/Teacher.

But I would like to restrict the plugin from even appearing as an option on the Add a block menu when they customise their dashboard.

I've tried using the applicable_formats function, but page is null so I can't access the context in order to call has_capability.

So all I've managed to do is make the block not even show if selected.  As it's set to only be allowed once, we could then auto add it to the dashboard and then restricted users wouldn't see it and it wouldn't appear on the menu.  But that seems a kludge to me.

Any better ideas?

Thanks

Average of ratings: -