WPDK
1.5.0
WordPress Development Kit
|
Public Member Functions | |
__construct ($user=0, $name= '', $blog_id= '') | |
Constructor. More... | |
create ($first_name, $last_name, $email, $password=false, $enabled=false, $role= 'subscriber') | |
Create a WordPress user. More... | |
getTransient ($transient) | |
Get. More... | |
getTransientTime ($transient) | |
Transient time. More... | |
setTransient ($transient, $value, $expiration=0) | |
Set. More... | |
gravatar ($size=40, $alt= '', $default="wavatar") | |
Return HTML img of gravatar. More... | |
avatar ($size=40) | |
WPDKHTMLTagImg. More... | |
age ($birthday) | |
Get the user age from birth date. More... | |
hasRoles ($roles) | |
Check if the current user has one or more roles. More... | |
hasCaps ($caps) | |
Check if an user has one or more capabilities. More... | |
Static Public Member Functions | |
static | current_user () |
Return the current user. More... | |
static | nice_name ($firstName, $lastName) |
Sanitize a nice name. More... | |
static | full_name ($firstName, $lastName, $nameFirst=true) |
Sanitize a full name. More... | |
static | getTransientWithUser ($transient, $user_id=null) |
Get. More... | |
static | getTransientTimeWithUser ($transient, $user_id=null) |
Transient time. More... | |
static | setTransientWithUser ($transient, $value, $expiration=0, $user_id=null) |
Set. More... | |
static | roleNameForUserID ($id_user) |
static | hasCap ($cap, $id_user=null) |
Check if an user has a specify capability. More... | |
static | allCapabilities () |
static | updateUserCapabilities ($id_user, $selected_caps, $capabilities) |
Data Fields | |
$first_name | |
First name. More... | |
$last_name | |
Last name. More... | |
$nice_name | |
Nice name. More... | |
$full_name | |
Full name. More... | |
$display_name | |
Display name. More... | |
Email user. More... | |
$status | |
Status. More... | |
$statusDescription | |
Status description. More... | |
The WPDKUser class is an extension of WordPress WP_User class.
In the WPDKUser class you find all method and properties loose in standard WordPress WP_User class.
Definition at line 183 of file wpdk-user.php.
__construct | ( | $user = 0 , |
|
$name = '' , |
|||
$blog_id = '' |
|||
) |
Constructor.
Create an instance of WPDKUser class
int | object | array | string | $user | Optional. User's ID, WP_User object, WPDKUser object, array. If 0 (zero) the current user is get |
string | $name | Optional. User's username |
int | string | $blog_id | Optional. Blog ID, defaults to current blog. |
Definition at line 287 of file wpdk-user.php.
age | ( | $birthday | ) |
Get the user age from birth date.
Return the age (in year) from a date in format YYYY-MM-DD or DD/MM/YYYY
string | $birthday | Birth of date. MySQL YYYY-MM-DD o in formato data unico vincolo per adesso è il supporto solo per data italiana, ovvero giorno/meso/anno |
Definition at line 608 of file wpdk-user.php.
|
static |
Restituisce la lista di tutte le capabilities attualmente presenti in WordPress, scorrendo tutti i ruoli presenti ed estraendo le capabilities.
Definition at line 743 of file wpdk-user.php.
avatar | ( | $size = 40 | ) |
This method is an alias of WPDKUsers::avatar(). Return on instance of WPDKHTMLTagImg class, FALSE otherwise.
int | $size | Optional. Gravatar size |
Definition at line 590 of file wpdk-user.php.
create | ( | $first_name, | |
$last_name, | |||
$email, | |||
$password = false , |
|||
$enabled = false , |
|||
$role = 'subscriber' |
|||
) |
Create a WordPress user.
This method is an alias of WPDKUsers::create()
string | $first_name | First name |
string | $last_name | Last name |
string | Email address | |
bool | string | $password | Optional. Clear password, if set to FALSE a random password is created |
bool | $enabled | Optional. If TRUE the user is enabled, FALSE to set in pending |
string | $role | Optional. User role, default 'subscriber' |
Definition at line 384 of file wpdk-user.php.
|
static |
Return the current user.
Return an instance of WPDKUser class for the current user logged in or null if no user found/logged in
Definition at line 266 of file wpdk-user.php.
|
static |
Sanitize a full name.
Merge first name and last name.
string | $firstName | First name |
string | $lastName | Last name |
bool | $nameFirst | Optional. Default to TRUE [firstname lastname]. Set to FALSE to invert order |
Definition at line 359 of file wpdk-user.php.
getTransient | ( | $transient | ) |
Get.
Get the value of transient for this WPDKUser object instance. If the transient does not exist or does not have a value, then the return value will be false.
apply_filters() Calls 'pre_user_transient_$transient' hook before checking the transient. Any value other than false will "short-circuit" the retrieval of the transient and return the returned value. apply_filters() Calls 'user_transient_$transient' hook, after checking the transient, with the transient value.
string | $transient | Transient name. Expected to not be SQL-escaped |
Definition at line 446 of file wpdk-user.php.
getTransientTime | ( | $transient | ) |
Transient time.
Return the transient user time
string | $transient | Transient name. Expected to not be SQL-escaped |
Definition at line 481 of file wpdk-user.php.
|
static |
Transient time.
Return the transient user time
string | $transient | Transient name. Expected to not be SQL-escaped |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 464 of file wpdk-user.php.
|
static |
Get.
Get the value of a user transient. If the transient does not exist or does not have a value, then the return value will be false.
apply_filters() Calls 'pre_user_transient_$transient' hook before checking the transient. Any value other than false will "short-circuit" the retrieval of the transient and return the returned value. apply_filters() Calls 'user_transient_$transient' hook, after checking the transient, with the transient value.
string | $transient | Transient name. Expected to not be SQL-escaped |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 409 of file wpdk-user.php.
gravatar | ( | $size = 40 , |
|
$alt = '' , |
|||
$default = "wavatar" |
|||
) |
Return HTML img of gravatar.
This method is an alias of WPDKUsers::gravatar(). Return the HTML markup for tag img. False otherwise.
int | $size | Optional. Gravatar size |
string | $alt | Optional. Alternate string for alt attribute |
string | $default | Optional. Gravatar ID for default (not found) gravatar image |
Definition at line 575 of file wpdk-user.php.
|
static |
Check if an user has a specify capability.
Restutuisce true se l'utente passato negli inputs (o l'utente corrente se non viene passato id utente) possiede un determinato permesso (capability)
string | $cap | Capability ID |
int | $id_user | Optional. User ID or null for get current user ID |
Definition at line 697 of file wpdk-user.php.
hasCaps | ( | $caps | ) |
Check if an user has one or more capabilities.
Return TRUE if the user has one or more capabilities.
string | array | $caps | Single string capability or array list |
Definition at line 718 of file wpdk-user.php.
hasRoles | ( | $roles | ) |
Check if the current user has one or more roles.
Return TRUE if the current user has one o more roles.
string | array | $roles | Single string or array list of roles. |
Definition at line 642 of file wpdk-user.php.
|
static |
Sanitize a nice name.
Compose the first letter of first name and append last name, Eg. John Gold -> J.Gold
string | $firstName | First name |
string | $lastName | Last name |
Definition at line 342 of file wpdk-user.php.
|
static |
Return the role name of a user
int | $id_user | User ID |
Definition at line 671 of file wpdk-user.php.
setTransient | ( | $transient, | |
$value, | |||
$expiration = 0 |
|||
) |
Set.
Set/update the value of transient for this WPDKUser object instance.
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
self::setTransientWithUser()
string | $transient | Transient name. Expected to not be SQL-escaped. |
mixed | $value | Transient value. Expected to not be SQL-escaped. |
int | $expiration | Time until expiration in seconds, default 0 |
Definition at line 552 of file wpdk-user.php.
|
static |
Set.
Set/update the value of a user transient.
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
apply_filters() Calls 'pre_set_user_transient_$transient' hook to allow overwriting the transient value to be stored. do_action() Calls 'set_user_transient_$transient' and 'setted_transient' hooks on success.
string | $transient | Transient name. Expected to not be SQL-escaped. |
mixed | $value | Transient value. Expected to not be SQL-escaped. |
int | $expiration | Time until expiration in seconds, default 0 |
int | $user_id | Optional. User ID. If null the current user id is used instead |
Definition at line 508 of file wpdk-user.php.
|
static |
Aggiunge e/o rimuove i permessi (capability) da un utente. L'aggiunta avviene eseguendo una match tra una lista di capability selezionate e una lista di confronto, che corrisponde in pratica alle capabilities che possono essere aggiunte. Senza il parametro $capabilities verrebbero prese in considerazione tutte le capabilities, cosa che ovviamente non va bene. In pratica questo metodo dice; in base a questa lista ($capabilities) quali tra quelle selezionate ($selected_caps) devo attivate/disattivare ?
int | $id_user | ID dell'utente |
array | $selected_caps | Lista delle capability da aggiungere |
array | $capabilities | Lista di confronto per capire quale capability aggiungere e quale rimuovere |
Definition at line 771 of file wpdk-user.php.
string $display_name |
string $email |
string $first_name |
First name.
The user first name. Same $user->get( 'first_name' )
Definition at line 192 of file wpdk-user.php.
string $full_name |
string $last_name |
Last name.
The user last name. Same $user->get( 'last_name' )
Definition at line 201 of file wpdk-user.php.
string $nice_name |
string $status |
string $statusDescription |
Status description.
WPDK Extension for status description
Definition at line 255 of file wpdk-user.php.