Custom event Listener not triggering
-
Hi,
During the user registration process, we offer three subscription options: Free, 1-year, and 3-year. We’ve implemented Fluent Forms for all three subscription types. Now, we face the need to assign varying points based on the subscription type.
I have used the Fluent Form action hook (“fluentform/submission_inserted”) to call the listeners of “3 distinct custom events” within Gamipress for each subscription type. But the listeners are not getting triggered. My code is as follows.
function jkyog_registration_activity_triggers( $triggers ) { $triggers['Registration JKYOG'] = array( 'jkyog_free_subscription_event' => __( 'Free Subscription', 'gamipress' ), 'jkyog_one_year_subscription_event' => __( '1 Year Subscription', 'gamipress' ), 'jkyog_three_years_subscription_event' => __( '3 Year Subscription', 'gamipress' ) ); return $triggers; } add_filter( 'gamipress_activity_triggers', 'jkyog_registration_activity_triggers' ); function jkyog_free_subscription_listener( $args ) { error_log(" inside jkyog FREE subscription LISTENER"); gamipress_trigger_event( array( 'event' => 'jkyog_free_subscription_event', 'user_id' => get_current_user_id() ) ); } function jkyog_one_year_subscription_listener( $args ) { error_log(" inside jkyog 1 YEAR subscription LISTENER"); gamipress_trigger_event( array( 'event' => 'jkyog_one_year_subscription_event', 'user_id' => get_current_user_id() ) ); } function jkyog_three_years_subscription_listener( $args ) { error_log(" inside jkyog 3 YEARS subscription LISTENER"); gamipress_trigger_event( array( 'event' => 'jkyog_three_years_subscription_event', 'user_id' => get_current_user_id() ) ); } add_action("fluentform/submission_inserted", "jky_membership_form_processor", 20, 3); /* Process JKYog Membership fluent forms * Reference: https://fluentforms.com/docs/fluentform_submission_inserted/ */ function jky_membership_form_processor($entryId, $formData, $form) { try { // Register Forms $registerFormIds = ["3", "4", "9", "10"]; // Upgrade Forms $upgradeFormIds = ["5", "6", "7", "8"]; // determine if current form is register form or upgrade form $isRegisterForm = in_array($form->id, $registerFormIds); $isUpgradeForm = in_array($form->id, $upgradeFormIds); if ($isRegisterForm || $isUpgradeForm) { error_log("In membership form processor registration/upgrade form"); if($isRegisterForm) { error_log("register form"); do_action("jkyog_one_year_subscription_listener", $entryId, $formData, $form); } else { error_log("upgrade form"); do_action("jkyog_three_years_subscription_listener", $entryId, $formData, $form); } } elseif ($form->id == 11) { error_log("In membership form processor free subscription"); do_action("jkyog_free_subscription_listener", $formData); } else { error_log("Unrecognized form with form id: " . $form->id); } } catch (Exception $e) { error_log("Exception while processing membership registration: ".$e->getMessage()); } }
Can someone kindly help identify why the listeners are not triggering?
The page I need help with: [log in to see the link]
- The topic ‘Custom event Listener not triggering’ is closed to new replies.