[wp-hackers] quick way to add dozen of new capabilities to existing role?

Andrew Nacin wp at andrewnacin.com
Tue Sep 7 15:16:12 UTC 2010

On Tue, Sep 7, 2010 at 10:45 AM, Davit Barbakadze <jayarjo at gmail.com> wrote:

> I've considered that, but potential number of queries kinda frightened
> me away. Looking at the source I just made up something like this:
> ...
> I wonder if there could be a problem with this?

I wouldn't try to circumvent the API, especially since we are considering
some changes in the near future, probably in 3.2. Making assumptions for the
underlying schema is not a good idea. You're probably fine with
WP_Role::add_cap(), but I'd either deal with the queries (it's only on
activation, and it really isn't that many) or toggle $this->use_db to off
before, then turn it back on before your last cap is added. But that still
seems a little hackish.

Also, WP_Roles is initialized on the $wp_roles global. Instead of creating
your own.

More information about the wp-hackers mailing list