The User Class in Cuisine is just an easier version of the functions already available in WordPress. It only concerns the current logged in user.

The User-class is available through Cuisine’s Wrapper System, so you can start using it by adding


to the top of your php-document.

Getting user info

WordPress handles User information in a variety of differently styled and named functions. We bring ‘em together in this class.

Here are some examples:

User::get( 'ID' ); // -> returns the current user ID
User::get( 'display-name' ); // -> returns the current user's display name
User::get( 'twitter-name' ); // -> returns user meta called "twitter-name"  

The User::get() function can get anything from the current User as long as it’s available as regular user-data (like e-mail and username) or user-meta (like ‘first_name’ ).

Roles & Capabilities

Checking wether or not a user can do certain tasks is critical for your security. In Cuisine we have two functions in the User class to deal with roles:

User::can( 'edit-options' ); //-> checks if this user has the capability to 'edit-options'

User::may( 'edit-options'); //-> adds the 'edit-options' capability to this user

User::hasRole( 'editor' ); //-> checks if this user has the role of editor

User::setRole( 'editor' ); //-> give this user editor-powers.