Ecommerce Shopify WordPress Discussion

Problem with Updating the DB in FlluentCRM upon Topic Completion in LearnDash

I'm fairly new to PHP. I have a wordpress site where I use an LMS plugin called LearnDash and a CRM called FluentCRM. I wrote a code snippet so that when a student finishes a topic in LearnDash it then updates the date of the custom field of that contact in fluentCRM to store the date of completion (I want to have an automation to check whether he/she has progressed more after 7 days and if not send them an email). But... it doesn't work. I have no idea why. I would greatly appreciate your help. I'm also attaching the links to the relevant documentations: Here's the code: add_action( 'learndash_topic_completed', 'update_fluentcrm_custom_field_on_topic_completion', 10, 2 ); function update_fluentcrm_custom_field_on_topic_completion( $user_id, $topic_id ) { // Initialize FluentCRM API $contactApi = FluentCrmApi('contacts'); try { // Retrieve contact using the provided user ID $contact = $contactApi->getContactByUserRef($user_id); if ($contact) { // Extract the email address from the retrieved contact $email = $contact->email; // Prepare contact data with the extracted email and custom field $data = [ 'email' => $email, 'custom_values' => [ 'utm_content' => 'updated' ] ]; // Create or update the contact with the specified data $contact = $contactApi->createOrUpdate($data); error_log("FluentCRM custom field 'utm_content' updated successfully for contact: $email"); } else { error_log("Contact not found in FluentCRM for user ID: $user_id"); } } catch (\Exception $e) { error_log("Error updating FluentCRM custom field: " . $e->getMessage()); } }
It seems like you're attempting to use WordPress hooks to update FluentCRM custom fields when a student finishes a topic in LearnDash. However, without seeing your code snippet, it's challenging to pinpoint the issue. Error Reporting :Check your error logs for any PHP errors or warnings. These logs can provide valuable information about what might be going wrong. WordPress Hooks: Ensure that your code is hooked into the appropriate WordPress action or filter. For LearnDash events, you might want to use hooks like learndash_course_completed or learndash_lesson_completed. FluentCRM API: Review the FluentCRM documentation to confirm that you are using the correct API functions to update custom fields. Pay attention to the function names, parameters, and usage. Code Structure: Ensure that your code snippet is properly structured. It should be placed in your theme's functions.php file or a custom plugin. Make sure there are no syntax errors or missing brackets WordPress Best Practices: Follow best practices when writing WordPress code. Use function_exists checks, escape data when necessary, and adhere to WordPress coding standards. if you want proper code send your mail i will give you coding on your mail

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.