Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Created March 20, 2025 21:41
Show Gist options
  • Save goranefbl/1c32ec1a1d1762d6dcb0c42839a82c41 to your computer and use it in GitHub Desktop.
Save goranefbl/1c32ec1a1d1762d6dcb0c42839a82c41 to your computer and use it in GitHub Desktop.
WPGens Points and Rewards hooks
<?php
/* Add points
do_action(
'wpgens_loyalty_update_points',
$user_id, // User ID
$points_amount, // Points to add (positive) or remove (negative)
WPGL_Points_Activity_Type::EARN, // Activity type (EARN or DEDUCT)
WPGL_Points_Source_Type::PLACE_ORDER, // Source type (see below)
$reference_id = null, // Optional reference ID (e.g., order ID)
$description = null // Optional description
);
// Remove points
do_action(
'wpgens_loyalty_update_points',
$user_id,
-$points_amount, // Negative value to remove points
WPGL_Points_Activity_Type::DEDUCT,
WPGL_Points_Source_Type::ORDER_DISCOUNT,
$reference_id,
$description
);
Example usage:
*/
// Add 100 points for a product review
do_action(
'wpgens_loyalty_update_points',
$user_id,
100,
WPGL_Points_Activity_Type::EARN,
WPGL_Points_Source_Type::PRODUCT_REVIEW,
$product_id,
'Product review for ' . $product_name
);
// Remove 50 points for a reward
do_action(
'wpgens_loyalty_update_points',
$user_id,
-50,
WPGL_Points_Activity_Type::DEDUCT,
WPGL_Points_Source_Type::REWARD_CLAIMED,
$reward_id,
'Redeemed reward: ' . $reward_name
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment