PHP Класс WPDKUser

## Overview In the WPDKUser class you find all method and properties loose in standard WordPress WP_User class.
Автор: =undo= ([email protected])
Наследование: extends WP_User
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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 ?

Описание методов

__construct() публичный Метод

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.
Результат WPDKUser

age() публичный Метод

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
Результат integer Age

allCapabilities() публичный статический Метод

Restituisce la lista di tutte le capabilities attualmente presenti in WordPress, scorrendo tutti i ruoli presenti ed estraendo le capabilities.
Устаревший:
public static allCapabilities ( ) : array
Результат array

avatar() публичный Метод

This method is an alias of WPDKUsers::avatar(). Return on instance of WPDKHTMLTagImg class, FALSE otherwise.
С версии: 1.4.8
public avatar ( integer $size = 40 ) : WPDKHTMLTagImg | boolean
$size integer Optional. Gravatar size
Результат WPDKHTMLTagImg | boolean

create() публичный Метод

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'
Результат integer | WP_Error

current_user() публичный статический Метод

Return an instance of WPDKUser class for the current user logged in or null if no user found/logged in
С версии: 1.4.21
public static current_user ( ) : WPDKUser
Результат WPDKUser

deleteTransient() публичный Метод

Delete a user transient for this WPDKUser object instance. Return TRUE if successful, FALSE otherwise
С версии: 1.5.1
public deleteTransient ( string $transient ) : boolean
$transient string Transient name. Expected to not be SQL-escaped.
Результат boolean

deleteTransientWithUser() публичный статический Метод

Delete a user transient. Return TRUE if successful, FALSE otherwise
С версии: 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
Результат boolean

full_name() публичный статический Метод

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.
Результат string

getTransient() публичный Метод

If the transient does not exist or does not have a value, then the return value will be false.
С версии: 1.4.8
public getTransient ( string $transient ) : mixed
$transient string Transient name. Expected to not be SQL-escaped
Результат mixed Value of transient

getTransientTime() публичный Метод

Return the transient user time
С версии: 1.4.8
public getTransientTime ( string $transient ) : integer
$transient string Transient name. Expected to not be SQL-escaped
Результат integer

getTransientTimeWithUser() публичный статический Метод

Return the transient user time
С версии: 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
Результат integer

getTransientWithUser() публичный статический Метод

If the transient does not exist or does not have a value, then the return value will be false.
С версии: 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
Результат mixed Value of transient

gravatar() публичный Метод

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
Результат string

hasCap() публичный статический Метод

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
Результат boolean True se l'utente supporta la capability

hasCaps() публичный Метод

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
Результат boolean Se almeno uno dei permessi è presente restituisce true, altrimenti false

hasRoles() публичный Метод

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.
Результат boolean TRUE if user has the role, else FALSE.

nice_name() публичный статический Метод

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
Результат string

roleNameForUserID() публичный статический Метод

Return the role name of a user
public static roleNameForUserID ( integer $id_user ) : boolean | string
$id_user integer User ID
Результат boolean | string Ruolo utente o FALSE se errore.

setTransient() публичный Метод

You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
С версии: 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
Результат boolean False if value was not set and true if value was set.

setTransientWithUser() публичный статический Метод

You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is set.
С версии: 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
Результат boolean False if value was not set and true if value was set.

set_role() публичный Метод

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.
С версии: 1.5.6
public set_role ( string $role )
$role string Role name.

updateUserCapabilities() публичный статический Метод

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

Описание свойств

$display_name публичное свойство

Replcement of $user->data->display_name
public string $display_name
Результат string

$email публичное свойство

Replcement of $user->data->user_email
public string $email
Результат string

$first_name публичное свойство

The user first name. Same $user->get( 'first_name' )
public string $first_name
Результат string

$full_name публичное свойство

Compose first name and last name
public string $full_name
Результат string

$last_name публичное свойство

The user last name. Same $user->get( 'last_name' )
public string $last_name
Результат string

$nice_name публичное свойство

The user nice name
public string $nice_name
Результат string

$status публичное свойство

WPDK Extension for status
public string $status
Результат string

$statusDescription публичное свойство

WPDK Extension for status description
public string $statusDescription
Результат string

$user_login публичное свойство

WordPress user login.
С версии: 1.7.2
public string $user_login
Результат string