Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action "llms_user_enrollment_deleted" error #2284

Closed
2 of 4 tasks
saracomin96 opened this issue Oct 6, 2022 · 2 comments
Closed
2 of 4 tasks

Action "llms_user_enrollment_deleted" error #2284

saracomin96 opened this issue Oct 6, 2022 · 2 comments
Assignees
Labels
invalid This issue or PR is invalid

Comments

@saracomin96
Copy link

saracomin96 commented Oct 6, 2022

Reproduction Steps

hi, i found this action that fires after the user is deleted from a course. I found a problem though, even if I use it without any function inside it, such as this:

function llms_user_enrollment_deleted_function($user_id, $product_id, $enrollment_trigger) {
}

add_action ('llms_user_enrollment_deleted', 'llms_user_enrollment_deleted_function');

In the course settings when I try to remove a user it remains pending like this:
image

When I refresh the page the user is deleted, but he shouldn't do that

Expected Behavior

user removals without infinite pending and function starting correctly

Actual Behavior

Infinite loading and internal functions are not performed
image

complete function
function llms_user_enrollment_deleted_function($user_id, $product_id, $enrollment_trigger) {

$contactApi = FluentCrmApi('contacts');
$user_info = get_userdata($user_id);
$emailAddress = $user_info->user_email;
$post_type = get_post_type( $product_id );

if($post_type == 'course' && metadata_exists( 'post', $product_id, 'wpcf-id_lista' )) {

$id_lista = get_post_meta($product_id, 'wpcf-id_lista', true);

if(!empty($id_lista)){

$contact = $contactApi->getContact($emailAddress);
$listIds = [$id_lista]; // 5 is the list ID
$contact->detachLists($listIds);
//return true;
}

}

return true;
}

add_action( 'llms_user_enrollment_deleted', 'llms_user_enrollment_deleted_function' );

Error Messages / Logs

  • Include any relevant error messages or log files
load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,jquery-ui-core,utils,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.0.2:2          POST https://academyblu1stg.wpengine.com/wp-admin/admin-ajax.php 500

image

System and Environment Information

System Report
Wordpress
-------------------------------------------

Home Url: https://academyblu1stg.wpengine.com
Site Url: https://academyblu1stg.wpengine.com
Login Url: https://academyblu1stg.wpengine.com/wp-login.php
Version: 6.0.2
Debug Mode: Yes
Debug Log: No
Debug Display: Yes
Locale: it_IT
Multisite: No
Page For Posts: Not Set
Page On Front: Home page (#322) [https://academyblu1stg.wpengine.com/]
Permalink Structure: /%postname%/
Show On Front: page
Wp Cron: Yes


Settings
-------------------------------------------

Version: 6.11.0
Db Version: 6.11.0
Course Catalog: Catalogo Corsi (#16) [https://academyblu1stg.wpengine.com/?page_id=16]
Membership Catalog: Catalogo Membership (#17) [https://academyblu1stg.wpengine.com/?page_id=17]
Student Dashboard: Bacheca (#19) [https://academyblu1stg.wpengine.com/dashboard/]
Checkout Page: Acquista (#18) [https://academyblu1stg.wpengine.com/purchase/]
Course Catalog Per Page: 9
Course Catalog Sorting: menu_order
Membership Catalog Per Page: 9
Membership Catalog Sorting: menu_order
Site Membership: Not Set
Courses Endpoint: my-courses
Edit Endpoint: modifica-account
Lost Password Endpoint: lost-password
Vouchers Endpoint: redeem-voucher
Autogenerate Username: no
Password Strength Meter: no
Minimum Password Strength: 
Terms Required: no
Terms Page: Not Set
Checkout Names: 
Checkout Address: 
Checkout Phone: 
Checkout Email Confirmation: no
Open Registration: no
Registration Names: 
Registration Address: 
Registration Phone: 
Registration Voucher: 
Registration Email Confirmation: no
Account Names: 
Account Address: 
Account Phone: 
Account Email Confirmation: no
Confirmation Endpoint: confirm-payment
Force Ssl Checkout: no
Country: IT
Currency: EUR
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Decimals: 2
Trim Zero Decimals: no
Recurring Payments: no
Email From Address: formazione@bluenext.it
Email From Name: Bluenext Academy
Email Footer Text: 
Email Header Image: 
Cert Bg Width: 800
Cert Bg Height: 616
Cert Legacy Compat: no


Constants
-------------------------------------------

LLMS_REMOVE_ALL_DATA: undefined
LLMS_REST_DISABLE: undefined
LLMS_SITE_FEATURE_RECURRING_PAYMENTS: undefined
LLMS_SITE_IS_CLONE: undefined


Gateways
-------------------------------------------

Stripe: Enabled
Stripe Test Mode: Enabled
Stripe Logging: no
Stripe Order: 1
Manuale: Disabled
Manuale Logging: no
Manuale Order: 1


Server
-------------------------------------------

Mysql Version: 5.7.39
Php Curl: Yes
Php Default Timezone: UTC
Php Fsockopen: Yes
Php Max Input Vars: 10000
Php Max Upload Size: 50 MB
Php Memory Limit: 512M
Php Post Max Size: 100M
Php Soap: Yes
Php Suhosin: No
Php Time Limt: 3600
Php Version: 7.4.28
Software: Apache
Wp Memory Limit: 40M


Browser
-------------------------------------------

HTTP USER AGENT: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36


Theme
-------------------------------------------

Name: LifterLMS LaunchPad Child
Version: 1.1.0
Themeuri: https://lifterlms.com/product/launchpad/
Authoruri: https://lifterlms.com
Template: lifterlms-launchpad
Child Theme: Yes
Llms Support: No


Plugins
-------------------------------------------

Elementor: 3.7.7
Elementor Pro: 3.7.7
Events Widgets For Elementor And The Events Calendar: 1.6
FluentCRM - Marketing Automation For WordPress: 2.5.95
Genesis Blocks: 1.5.1
Import Users from CSV: 1.1
LifterLMS: 6.11.0
LifterLMS Blocks: 2.4.0
LifterLMS Custom Fields: 2.0.2
LifterLMS Labs: 1.6.0
LifterLMS Stripe Payment Gateway: 5.4.0
LifterLMS WPForms: 1.1.1
Login as User: 1.4.4
OTGS Installer: 3.0.3
Simple Custom CSS and JS: 3.40
The Events Calendar: 6.0.1
Toolset Blocks: 1.6.3
Toolset Module Manager: 1.8.8
Toolset Types: 3.4.16
Users Insights: 4.2.1
WP All Export: 1.3.7
WP Engine Smart Plugin Manager: 5.10.4
WPForms: 1.7.7
WPForms Geolocation: 2.3.1
WPForms Post Submissions: 1.4.0
WPForms User Registration: 2.1.0
WP Mail Logging: 1.10.4
Yoast Duplicate Post: 4.5


Integrations
-------------------------------------------

BbPress: No
BuddyPress: No
LifterLMS WPForms: No


Template Overrides
-------------------------------------------

content-certificate.php (ver: 6.0.0): /nas/content/live/academyblu1stg/wp-content/themes/lifterlms-launchpad-child-trunk//lifterlms/ (ver: 4.21.0)
checkout/form-checkout.php (ver: 5.0.0): /nas/content/live/academyblu1stg/wp-content/themes/lifterlms-launchpad-child-trunk//lifterlms/ (ver: 5.0.0)
emails/header.php (ver: 3.16.15): /nas/content/live/academyblu1stg/wp-content/themes/lifterlms-launchpad-child-trunk//lifterlms/ (ver: 3.16.15)



This issue has be recreated:

  • Locally
  • On a staging site
  • On a production website
  • With only LifterLMS and a default theme
@thomasplevy thomasplevy self-assigned this Oct 6, 2022
@eri-trabiccolo
Copy link
Collaborator

Hi Sara,
thanks for reporting this.

Looks like you're using add_action() the wrong way.
You defined a callback that requires 3 parameters:
function llms_user_enrollment_deleted_function($user_id, $product_id, $enrollment_trigger) {
But you're passing only one parameter:
add_action ('llms_user_enrollment_deleted', 'llms_user_enrollment_deleted_function');

The latter should be:
add_action ('llms_user_enrollment_deleted', 'llms_user_enrollment_deleted_function', 10, 3);
Where 10 is the default priority, and 3 the number of parameters passed to the callback.
See: https://developer.wordpress.org/plugins/hooks/actions/

Also if enabling the WordPress debug (debug log even better), will help you troubleshooting PHP errors in the code.
See: https://lifterlms.com/docs/how-to-debug-a-white-screen/#log

Hope this helps.

@eri-trabiccolo eri-trabiccolo added the invalid This issue or PR is invalid label Oct 6, 2022
@saracomin96
Copy link
Author

It worked! thank so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This issue or PR is invalid
Projects
Archived in project
Development

No branches or pull requests

3 participants