Subtract points when submitting a wpform
-
Good day
I want to subtract points for User A when User B submits a specific wpform. The two users have different roles and only B can access the form made by wpforms. When the form is submitted successfully, 20 points must be subtracted from User A. The form is located on the profile page of User A. The form automatically records User B’s display name in a hidden field and also the Display name of the User A’s profile. The profile is created using Ultimate Member. I used the following code to capture the User A’s user ID based on the current user profile that User B is visiting. Everything works as intended except that the points are not being deducted from User A and there are no log entries either. The code should theoretically run the moment the form is submitted successfully. If I debug by echoing the the profile id and also the profile display name, then it seems to display the correct information:
function subtract_vp( $fields, $entry, $form_data, $entry_id ) { //Limits to for 734 if (734 != $form_data['id']) return; //Gets the current profile ID $profile_id = um_profile_id(); //Subtracts 20 points from this profile's user mycred_subtract( 'penalty', $profile_id, -20, 'Points used' ); } add_action( 'wpforms_process_complete', 'subtract_vp', 10, 4 );
It is probably something small or stupid, but any help will be appreciated.
- The topic ‘Subtract points when submitting a wpform’ is closed to new replies.