WPDK  1.5.0
WordPress Development Kit
 All Data Structures Files Functions Variables Pages
WPDKUser Class Reference
Inheritance diagram for WPDKUser:

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
 Email user. More...
 
 $status
 Status. More...
 
 $statusDescription
 Status description. More...
 

Detailed Description

The WPDKUser class is an extension of WordPress WP_User class.

Overview

In the WPDKUser class you find all method and properties loose in standard WordPress WP_User class.

Author
=undo= info@.nosp@m.wpxt.nosp@m.re.me
Date
2014-02-11
Version
1.0.1

Definition at line 183 of file wpdk-user.php.

Constructor & Destructor Documentation

__construct (   $user = 0,
  $name = '',
  $blog_id = '' 
)

Constructor.

Create an instance of WPDKUser class

Parameters
int | object | array | string$userOptional. User's ID, WP_User object, WPDKUser object, array. If 0 (zero) the current user is get
string$nameOptional. User's username
int | string$blog_idOptional. Blog ID, defaults to current blog.
Returns
WPDKUser

Definition at line 287 of file wpdk-user.php.

Member Function Documentation

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

Parameters
string$birthdayBirth of date. MySQL YYYY-MM-DD o in formato data unico vincolo per adesso è il supporto solo per data italiana, ovvero giorno/meso/anno
Returns
int Age

Definition at line 608 of file wpdk-user.php.

static allCapabilities ( )
static

Restituisce la lista di tutte le capabilities attualmente presenti in WordPress, scorrendo tutti i ruoli presenti ed estraendo le capabilities.

Deprecated:
Returns
array

Definition at line 743 of file wpdk-user.php.

avatar (   $size = 40)

WPDKHTMLTagImg.

This method is an alias of WPDKUsers::avatar(). Return on instance of WPDKHTMLTagImg class, FALSE otherwise.

Since
1.4.8
Parameters
int$sizeOptional. Gravatar size
Returns
WPDKHTMLTagImg|bool

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()

Parameters
string$first_nameFirst name
string$last_nameLast name
string$emailEmail address
bool | string$passwordOptional. Clear password, if set to FALSE a random password is created
bool$enabledOptional. If TRUE the user is enabled, FALSE to set in pending
string$roleOptional. User role, default 'subscriber'
Returns
int|WP_Error

Definition at line 384 of file wpdk-user.php.

static current_user ( )
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

Since
1.4.21
Returns
WPDKUser

Definition at line 266 of file wpdk-user.php.

static full_name (   $firstName,
  $lastName,
  $nameFirst = true 
)
static

Sanitize a full name.

Merge first name and last name.

Parameters
string$firstNameFirst name
string$lastNameLast name
bool$nameFirstOptional. Default to TRUE [firstname lastname]. Set to FALSE to invert order
Returns
string

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.

Since
1.4.8

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.

Parameters
string$transientTransient name. Expected to not be SQL-escaped
Returns
mixed Value of transient

Definition at line 446 of file wpdk-user.php.

getTransientTime (   $transient)

Transient time.

Return the transient user time

Since
1.4.8
Parameters
string$transientTransient name. Expected to not be SQL-escaped
Returns
int

Definition at line 481 of file wpdk-user.php.

static getTransientTimeWithUser (   $transient,
  $user_id = null 
)
static

Transient time.

Return the transient user time

Since
1.4.8
Parameters
string$transientTransient name. Expected to not be SQL-escaped
int$user_idOptional. User ID. If null the current user id is used instead
Returns
int

Definition at line 464 of file wpdk-user.php.

static getTransientWithUser (   $transient,
  $user_id = null 
)
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.

Since
1.4.8

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.

Parameters
string$transientTransient name. Expected to not be SQL-escaped
int$user_idOptional. User ID. If null the current user id is used instead
Returns
mixed Value of transient

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.

Parameters
int$sizeOptional. Gravatar size
string$altOptional. Alternate string for alt attribute
string$defaultOptional. Gravatar ID for default (not found) gravatar image
Returns
string

Definition at line 575 of file wpdk-user.php.

static hasCap (   $cap,
  $id_user = null 
)
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)

Parameters
string$capCapability ID
int$id_userOptional. User ID or null for get current user ID
Returns
bool True se l'utente supporta la capability

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.

Parameters
string | array$capsSingle string capability or array list
Returns
bool Se almeno uno dei permessi è presente restituisce true, altrimenti false

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.

Parameters
string | array$rolesSingle string or array list of roles.
Returns
bool TRUE if user has the role, else FALSE.

Definition at line 642 of file wpdk-user.php.

static nice_name (   $firstName,
  $lastName 
)
static

Sanitize a nice name.

Compose the first letter of first name and append last name, Eg. John Gold -> J.Gold

Parameters
string$firstNameFirst name
string$lastNameLast name
Returns
string

Definition at line 342 of file wpdk-user.php.

static roleNameForUserID (   $id_user)
static

Return the role name of a user

Parameters
int$id_userUser ID
Returns
bool|string Ruolo utente o FALSE se errore.

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.

Since
1.3.0

self::setTransientWithUser()

Parameters
string$transientTransient name. Expected to not be SQL-escaped.
mixed$valueTransient value. Expected to not be SQL-escaped.
int$expirationTime until expiration in seconds, default 0
Returns
bool False if value was not set and true if value was set.

Definition at line 552 of file wpdk-user.php.

static setTransientWithUser (   $transient,
  $value,
  $expiration = 0,
  $user_id = null 
)
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.

Since
1.3.0

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.

Parameters
string$transientTransient name. Expected to not be SQL-escaped.
mixed$valueTransient value. Expected to not be SQL-escaped.
int$expirationTime until expiration in seconds, default 0
int$user_idOptional. User ID. If null the current user id is used instead
Returns
bool False if value was not set and true if value was set.

Definition at line 508 of file wpdk-user.php.

static updateUserCapabilities (   $id_user,
  $selected_caps,
  $capabilities 
)
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 ?

Parameters
int$id_userID dell'utente
array$selected_capsLista delle capability da aggiungere
array$capabilitiesLista di confronto per capire quale capability aggiungere e quale rimuovere

Definition at line 771 of file wpdk-user.php.

Field Documentation

string $display_name

Display name.

Replcement of $user->data->display_name

Definition at line 228 of file wpdk-user.php.

string $email

Email user.

Replcement of $user->data->user_email

Definition at line 237 of file wpdk-user.php.

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

Full name.

Compose first name and last name

Definition at line 219 of file wpdk-user.php.

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

Nice name.

The user nice name

Definition at line 210 of file wpdk-user.php.

string $status

Status.

WPDK Extension for status

Definition at line 246 of file wpdk-user.php.

string $statusDescription

Status description.

WPDK Extension for status description

Definition at line 255 of file wpdk-user.php.


The documentation for this class was generated from the following file: