Support » Plugin: myCred - Points, Rewards, Gamification, Ranks, Badges & Loyalty Plugin » Subtract points when submitting a wpform

  • Resolved freedomsoftwareza

    (@freedomsoftwareza)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • A.Tariq

    (@arsalantariq)

    @freedomsoftwareza,

    Thank you for contacting us, The point will either be added or subtracted based on the value that has been set in the specific wp forms hook. The points will be awarded to the user who is submitting the form. If you set a negative value in the hook then the points will be deducted for the user who is submitting the form. Currently, we do not have any such option to reward the specific user with points while deducting points from the other user.

    A.Tariq

    (@arsalantariq)

    @freedomsoftwareza,

    Due to a lack of activity, we are going to mark this thread as resolved. If you have any other issues, please feel free to open a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Subtract points when submitting a wpform’ is closed to new replies.