I'm trying to add items to the admin bar but only for users with certain capabilities, such as
add_movies in a plugin. The problem is that, according to @toscho and @TheDeadMedic, the plugin executes its code too early in the order of operations to use
I tried using
if ($user->has_cap('add_movies')) but get
Fatal error: Call to a member function has_cap() on a non-object in xxx.
Am I missing an obvious global or is the solution more complicated?