With the WPGens Points and Rewards for WooCommerce plugin, you can go beyond the default earning rules and award or deduct points based on custom actions performed by your users.
This is useful when you want to reward customer engagement outside the usual order flow – such as completing a quiz, interacting on social media, or performing actions tracked by other plugins.
By using the wpgens_loyalty_update_points action hook, you can seamlessly integrate these events into your loyalty program and keep point tracking consistent across your store.
// Award points for a custom action
function award_custom_points($user_id, $points, $description) {
do_action(
'wpgens_loyalty_update_points',
$user_id,
$points,
'add',
'custom_action',
null,
$description
);
}
// Example: Award points for completing a quiz
add_action('quiz_completed', function($user_id, $quiz_id) {
$points = 100; // Award 100 points
$description = sprintf('Completed quiz #%d', $quiz_id);
award_custom_points($user_id, $points, $description);
});
// Example: Award points for social media engagement
add_action('social_media_engagement', function($user_id, $platform, $action) {
$points = 50; // Award 50 points
$description = sprintf('Engaged on %s: %s', $platform, $action);
award_custom_points($user_id, $points, $description);
});
// Example: Integration with another plugin
add_action('other_plugin_custom_event', function($user_id, $event_data) {
// Calculate points based on event data
$points = calculate_points_from_event($event_data);
$description = sprintf('Completed %s', $event_data['event_name']);
do_action(
'wpgens_loyalty_update_points',
$user_id,
$points,
'add',
'other_plugin',
$event_data['event_id'],
$description
);
});
// Example: Deduct points for a penalty
function deduct_points_penalty($user_id, $points, $reason) {
do_action(
'wpgens_loyalty_update_points',
$user_id,
$points,
'deduct',
'penalty',
null,
$reason
);
}