To retrieve data about Plesk user, use the
pm_Client
class.
The
pm_Client
class represents a Plesk user account. This class supports retrieving
information about a user either by their ID or by their username:
Alternatively, the entire list of all users can be retrieved:
pm_Client
also lets you identify a user’s account type:
administrator, reseller, or customer:
The next method lets you retrieve any user information from the clients
table in the Plesk database psa
:
Finally, the following methods check for assigned permissions:
Storing and Retrieving User-specific Data
It is possible to store and retrieve arbitrary data for a specific user.
The following methods add new data records, retrieve existing data and
remove records that are no longer needed:
Note: These serve as a key-value storage for a specific
user.
Example: Retrieving information about the user
$client = pm_Client::getByClientId($id);
echo "Hello, {$client->getProperty('login')}";
if ($client->isAdmin()) {
echo "You are admin";
} elseif ($client->isReseller()) {
echo "You are reseller";
} elseif ($client->isClient()) {
echo "You are customer";
}
Example: Retrieving user ID by username
$client = pm_Client::getByLogin($login);
echo "Your ID is {$client->getId()}";