Skip to content
site logo mobile

Code Snippets Library >

Check User points balance

🔑 ID:

12754

👨‍💻

PHP

🕒

24/12/2023
Free

Description:

Check if the user has enough points (MyCred) before using our tools. We use this in our WordPress SaaS system.

Code:

// Retrieve user ID and balance only if the user is logged in
$points_required = 5;
$user_id = get_current_user_id();
$balance = mycred_get_users_balance($user_id);

// Check if the user's balance meets the requirement
if ($balance < $points_required)
    {
        return;
    }

 

Untitled design (82)

GitHub Link

✖️ Not Available

Untitled design (83)

Download File

✖️ Not Available

If you’re encountering any problems or need further assistance with this code, we’re here to help! Join our community on the forum or Discord for support, tips, and discussion.