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
Cuisine\Wrappers\User
to the top of your php-document.
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"
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:
//capabilities:
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
//roles:
User::hasRole( 'editor' ); //-> checks if this user has the role of editor
User::setRole( 'editor' ); //-> give this user editor-powers.