DocumentationDevelopers
These functions are used for managing the points, referral count, user level, and user experience in the Crown Points system. Each function serves a specific purpose and either retrieves or updates user meta data.
crown_get_points_balance();
This function retrieves the points balance for a user. If no user ID is provided, it defaults to the current logged-in user’s ID.
Example usage:
$points = crown_get_points_balance($user_id);
echo 'User Points Balance: ' . $points;
crown_get_referrals_count();
This function retrieves the number of referrals for a user. If no user ID is provided, it defaults to the current logged-in user’s ID.
Example usage:
$referrals = crown_get_referrals_count($user_id);
echo 'User Referrals Count: ' . $referrals;
In this example, crown_get_referrals_count();
returns the number of referrals for the user with the given $user_id
crown_get_user_level();
This function retrieves the user level. If no user ID is provided, it defaults to the current logged-in user’s ID.
Example usage:
$user_level = crown_get_user_level($user_id);
echo 'User Level: ' . $user_level;
In this example, crown_get_user_level();
returns the level of the user with the given $user_id
crown_update_points();
Example usage:
// To add points
crown_update_points(10, $user_id, 'plus');
// To subtract points
crown_update_points(5, $user_id, 'minus');
In these examples, crown_update_points();
updates the points balance of the user with the given $user_id
based on the amount and operation plus
or minus
crown_update_experience();
This function updates a user’s experience. You provide the amount of experience to be added and the user ID.
Example usage:
crown_update_experience(20, $user_id);
In this example, crown_update_experience();
adds 20 experience points to the user with the given $user_id