PHP Class WPDKUser

## Overview In the WPDKUser class you find all method and properties loose in standard WordPress WP_User class.
Author: =undo= ([email protected])
Inheritance: extends WP_User
Mostra file Open project: wpxtreme/wpdk Class Usage Examples

Public Properties

Property Type Description
$display_name string Replcement of $user->data->display_name
$email string Replcement of $user->data->user_email
$first_name string The user first name. Same $user->get( 'first_name' )
$full_name string Compose first name and last name
$last_name string The user last name. Same $user->get( 'last_name' )
$nice_name string The user nice name
$status string WPDK Extension for status
$statusDescription string WPDK Extension for status description
$user_login string WordPress user login.

Public Methods

Method Description
__construct ( integer | object | array | string $user, string $name = '', integer | string $blog_id = '' ) : WPDKUser Create an instance of WPDKUser class
age ( string $birthday ) : integer Return the age (in year) from a date in format YYYY-MM-DD or DD/MM/YYYY
allCapabilities ( ) : array Restituisce la lista di tutte le capabilities attualmente presenti in WordPress, scorrendo tutti i ruoli presenti ed estraendo le capabilities.
avatar ( integer $size = 40 ) : WPDKHTMLTagImg | boolean This method is an alias of WPDKUsers::avatar(). Return on instance of WPDKHTMLTagImg class, FALSE otherwise.
create ( string $first_name, string $last_name, string $email, boolean | string $password = false, boolean $enabled = false, string $role = 'subscriber' ) : integer | WP_Error This method is an alias of WPDKUsers::create()
current_user ( ) : WPDKUser Return an instance of WPDKUser class for the current user logged in or null if no user found/logged in
deleteTransient ( string $transient ) : boolean Delete a user transient for this WPDKUser object instance. Return TRUE if successful, FALSE otherwise
deleteTransientWithUser ( string $transient, integer $user_id = null ) : boolean Delete a user transient. Return TRUE if successful, FALSE otherwise
full_name ( string $firstName, string $lastName, boolean $nameFirst = true ) : string Return a full name by first and last name.
getTransient ( string $transient ) : mixed Get the value of transient for this WPDKUser object instance.
getTransientTime ( string $transient ) : integer Return the transient user time
getTransientTimeWithUser ( string $transient, integer $user_id = null ) : integer Return the transient user time
getTransientWithUser ( string $transient, integer $user_id = null ) : mixed Get the value of a user transient.
gravatar ( integer $size = 40, string $alt = '', string $default = "wavatar" ) : string This method is an alias of WPDKUsers::gravatar(). Return the HTML markup for tag img. False otherwise.
hasCap ( string $cap, integer $id_user = null ) : boolean Restutuisce true se l'utente passato negli inputs (o l'utente corrente se non viene passato id utente) possiede un determinato permesso (capability)
hasCaps ( string | array $caps ) : boolean Return TRUE if the user has one or more capabilities.
hasRoles ( string | array $roles ) : boolean Return TRUE if the current user has one o more roles.
nice_name ( string $firstName, string $lastName ) : string Return a nice name by vompose the first letter of first name and append last name, Eg. John Gold -> J.Gold.
roleNameForUserID ( integer $id_user ) : boolean | string Return the role name of a user
setTransient ( string $transient, mixed $value, integer $expiration ) : boolean Set/update the value of transient for this WPDKUser object instance.
setTransientWithUser ( string $transient, mixed $value, integer $expiration, integer $user_id = null ) : boolean Set/update the value of a user transient.
set_role ( string $role ) Set the role of the user. Perform a cache clear for this user.
updateUserCapabilities ( integer $id_user, array $selected_caps, array $capabilities ) 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 ?

Method Details

__construct() public method

Create an instance of WPDKUser class
public __construct ( integer | object | array | string $user, string $name = '', integer | string $blog_id = '' ) : WPDKUser
$user integer | object | array | string Optional. User's ID, WP_User object, WPDKUser object, array. If 0 (zero) the current user is get
$name string Optional. User's username
$blog_id integer | string Optional. Blog ID, defaults to current blog.
return WPDKUser

age() public method

Return the age (in year) from a date in format YYYY-MM-DD or DD/MM/YYYY
public age ( string $birthday ) : integer
$birthday string 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
return integer Age

allCapabilities() public static method

Restituisce la lista di tutte le capabilities attualmente presenti in WordPress, scorrendo tutti i ruoli presenti ed estraendo le capabilities.
Deprecation:
public static allCapabilities ( ) : array
return array

avatar() public method

This method is an alias of WPDKUsers::avatar(). Return on instance of WPDKHTMLTagImg class, FALSE otherwise.
Since: 1.4.8
public avatar ( integer $size = 40 ) : WPDKHTMLTagImg | boolean
$size integer Optional. Gravatar size
return WPDKHTMLTagImg | boolean

create() public method

This method is an alias of WPDKUsers::create()
public create ( string $first_name, string $last_name, string $email, boolean | string $password = false, boolean $enabled = false, string $role = 'subscriber' ) : integer | WP_Error
$first_name string First name
$last_name string Last name
$email string Email address
$password boolean | string Optional. Clear password, if set to FALSE a random password is created
$enabled boolean Optional. If TRUE the user is enabled, FALSE to set in pending
$role string Optional. User role, default 'subscriber'
return integer | WP_Error

current_user() public static method

Return an instance of WPDKUser class for the current user logged in or null if no user found/logged in
Since: 1.4.21
public static current_user ( ) : WPDKUser
return WPDKUser

deleteTransient() public method

Delete a user transient for this WPDKUser object instance. Return TRUE if successful, FALSE otherwise
Since: 1.5.1
public deleteTransient ( string $transient ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
return boolean

deleteTransientWithUser() public static method

Delete a user transient. Return TRUE if successful, FALSE otherwise
Since: 1.5.1
public static deleteTransientWithUser ( string $transient, integer $user_id = null ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
$user_id integer Optional. User ID. If null the current user id is used instead
return boolean

full_name() public static method

Return a full name by first and last name.
public static full_name ( string $firstName, string $lastName, boolean $nameFirst = true ) : string
$firstName string First name.
$lastName string Last name.
$nameFirst boolean Optional. Default to TRUE [firstname lastname]. Set to FALSE to reverse order.
return string

getTransient() public method

If the transient does not exist or does not have a value, then the return value will be false.
Since: 1.4.8
public getTransient ( string $transient ) : mixed
$transient string Transient name. Expected to not be SQL-escaped
return mixed Value of transient

getTransientTime() public method

Return the transient user time
Since: 1.4.8
public getTransientTime ( string $transient ) : integer
$transient string Transient name. Expected to not be SQL-escaped
return integer

getTransientTimeWithUser() public static method

Return the transient user time
Since: 1.4.8
public static getTransientTimeWithUser ( string $transient, integer $user_id = null ) : integer
$transient string Transient name. Expected to not be SQL-escaped
$user_id integer Optional. User ID. If null the current user id is used instead
return integer

getTransientWithUser() public static method

If the transient does not exist or does not have a value, then the return value will be false.
Since: 1.4.8
public static getTransientWithUser ( string $transient, integer $user_id = null ) : mixed
$transient string Transient name. Expected to not be SQL-escaped
$user_id integer Optional. User ID. If null the current user id is used instead
return mixed Value of transient

gravatar() public method

This method is an alias of WPDKUsers::gravatar(). Return the HTML markup for tag img. False otherwise.
public gravatar ( integer $size = 40, string $alt = '', string $default = "wavatar" ) : string
$size integer Optional. Gravatar size
$alt string Optional. Alternate string for alt attribute
$default string Optional. Gravatar ID for default (not found) gravatar image
return string

hasCap() public static method

Restutuisce true se l'utente passato negli inputs (o l'utente corrente se non viene passato id utente) possiede un determinato permesso (capability)
public static hasCap ( string $cap, integer $id_user = null ) : boolean
$cap string Capability ID
$id_user integer Optional. User ID or null for get current user ID
return boolean True se l'utente supporta la capability

hasCaps() public method

Return TRUE if the user has one or more capabilities.
public hasCaps ( string | array $caps ) : boolean
$caps string | array Single string capability or array list
return boolean Se almeno uno dei permessi è presente restituisce true, altrimenti false

hasRoles() public method

Return TRUE if the current user has one o more roles.
public hasRoles ( string | array $roles ) : boolean
$roles string | array Single string or array list of roles.
return boolean TRUE if user has the role, else FALSE.

nice_name() public static method

If the first and last name are empty, return an empty string. If the firstname is empty, return last name and viceversa.
public static nice_name ( string $firstName, string $lastName ) : string
$firstName string First name
$lastName string Last name
return string

roleNameForUserID() public static method

Return the role name of a user
public static roleNameForUserID ( integer $id_user ) : boolean | string
$id_user integer User ID
return boolean | string Ruolo utente o FALSE se errore.

setTransient() public method

You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
Since: 1.3.0
public setTransient ( string $transient, mixed $value, integer $expiration ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
$value mixed Transient value. Expected to not be SQL-escaped.
$expiration integer Time until expiration in seconds, default 0
return boolean False if value was not set and true if value was set.

setTransientWithUser() public static method

You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
Since: 1.3.0
public static setTransientWithUser ( string $transient, mixed $value, integer $expiration, integer $user_id = null ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
$value mixed Transient value. Expected to not be SQL-escaped.
$expiration integer Time until expiration in seconds, default 0
$user_id integer Optional. User ID. If null the current user id is used instead
return boolean False if value was not set and true if value was set.

set_role() public method

This will remove the previous roles of the user and assign the user the new one. You can set the role to an empty string and it will remove all of the roles from the user.
Since: 1.5.6
public set_role ( string $role )
$role string Role name.

updateUserCapabilities() public static method

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 ?
public static updateUserCapabilities ( integer $id_user, array $selected_caps, array $capabilities )
$id_user integer ID dell'utente
$selected_caps array Lista delle capability da aggiungere
$capabilities array Lista di confronto per capire quale capability aggiungere e quale rimuovere

Property Details

$display_name public_oe property

Replcement of $user->data->display_name
public string $display_name
return string

$email public_oe property

Replcement of $user->data->user_email
public string $email
return string

$first_name public_oe property

The user first name. Same $user->get( 'first_name' )
public string $first_name
return string

$full_name public_oe property

Compose first name and last name
public string $full_name
return string

$last_name public_oe property

The user last name. Same $user->get( 'last_name' )
public string $last_name
return string

$nice_name public_oe property

The user nice name
public string $nice_name
return string

$status public_oe property

WPDK Extension for status
public string $status
return string

$statusDescription public_oe property

WPDK Extension for status description
public string $statusDescription
return string

$user_login public_oe property

WordPress user login.
Since: 1.7.2
public string $user_login
return string