Award GamiPress on visiting Woo Products

Trigger To Award GamiPress On Visiting

Share This Post

Trigger to Award GamiPress (Points/Badges/Ranks) on visiting WooCommerce Products/Specific Products

It’s very common to award GamiPress points/badges/ranks on users’ visit at any page on GamiPess site according to its default achievement system and surely there isn’t any option to award points/badges/ranks on visiting custom post-type posts only, but how amazing it is, if you eagerly like to add this feature simply to GamiPress and experience it.

All the snippets below will be used for WooCommerce “Product” post-type. As an example. Users will be getting points/badges/ranks on visiting WooCommerce products or specific product pages.

Note: GamiPress and WooCommerce plugins must be configured in order to use these snippets.

Let’s Check it now;

Snippet 1: Add new trigger to the gamipress

This snippet will add a new trigger (heading) to GamiPress as rest of the default triggers shown in drop down.

 *  Add new trigger to the gamipress 
function ldninjas_gamipress_new_trigger( $triggers ) {
    $triggers['Award Points on Visiting WooCommerce Products'] = array(
        'visiting_woocommerce_product' => __( 'On visiting WooCommerce Product', 'gamipress-new-trigger' ),

    return $triggers;
add_filter( 'gamipress_activity_triggers', 'ldninjas_gamipress_new_trigger' );

Snippet 2: List WooCommerce Products to the trigger

This snippet will easily list all the WooCommerce products to the triggers.

 * List WooCommerce Products to the trigger
function ldninjas_specific_activity_trigger_completing_lesson( $specific_triggers ) {
    $specific_triggers['visiting_woocommerce_product'] = array( 'product' );

    return $specific_triggers;
add_filter( 'gamipress_specific_activity_triggers', 'ldninjas_specific_activity_trigger_completing_lesson' );

Snippet 3: Title for sub trigger

This snippet will be used to display label on GamiPress activity log.

 * Title for sub trigger
function ldninjas_specific_activity_trigger_label( $specific_trigger_labels ) {
    $specific_trigger_labels['visiting_woocommerce_product'] = __( 'Visit WooCommerce Products', 'gamipress-new-trigger' );

    return $specific_trigger_labels;
add_filter( 'gamipress_specific_activity_trigger_label', 'ldninjas_specific_activity_trigger_label' );

Snippet 4: Award Points/Badges/ranks

This snippet will award points/badges/ranks to WooCommerce/specific products on visiting it.

 * Award Points/Badges/ranks
function ldninjas_award_points_on_visiting_woo_product() {
    if( is_admin() || ! is_user_logged_in() || ! is_product() ) {

    gamipress_trigger_event( array(
        'event'       => 'visiting_woocommerce_product',
        'user_id'     => get_current_user_id(),
        'specific_id' => get_the_ID()

    ) );
add_action( 'wp', 'ldninjas_award_points_on_visiting_woo_product' );


So, All you need to add this code snippet to your theme functions.php file to award points/badges/ranks on visiting custom post-type posts only. Enjoy!

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

How To Get Admin User ID

How to get admin user ID

Share This Post How to get admin User ID? It’s been really difficult for many to get back the admin user ID but it’s so

Award GamiPress On RCPro Membership Renewal

Award GamiPress on RCPro Membership Renewal

Share This Post Award GamiPress on RCPro Membership Renewal Do you think users can also be awarded points/badges/ranks while RCPro Membership renewal? Yes, you can

Custom Message With MyCRED Transfer

Custom Message with myCRED Transfer

Share This Post Custom Message with myCRED Transfer MyCred assigns different points to the users but it’s been sometime noticed that the users want to

Want To Know About Our Services?


Let’s Talk To Us With Your Concerns

    Once you send the details, we will be shortly back to you. Thanks!

    Use coupon code "FSBFCM2023" to get 30% discount on any plugin purchase!

    Become a valuable part of Team LDninjas


    Be updated with new release by LDninjas!