Gravity forms add points from number field.

front page Forums Community Gravity forms add points from number field.

  • This topic has 17 replies, 4 voices, and was last updated 3 months ago by AvatarCarlenY.
Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #12879
    AvatarWPExperts

    Hey Simon. If you find a solution, please feel free to post an update. I am sure there would be others that would find it useful.

    #33734
    AvatarForestNation

    Hi Simon Bame,
    Did you find a solution to this?

    I need something similar. I am using Gravity Forms for quiz system (not with the quiz add on).
    I am using a number field which calculates the total points.
    Labelling the field mycred_amount doesn’t work unless there is a fixed amount as the default value. It doesn’t recognise any calculated amount.

    Gabriel, could your snippet be tweaked to apply to just one or a few Gravity Forms so we can leave the hook active also?

    #63737
    AvatarCarlenY

    For anyone still looking to do this here is some code that worked for me. In this example it is form 2 and I am using a number field 5 and a single line text field in 11. The number field is a calculated filed. The single line text field just holds their user id.

    This goes in your functions file:

    add_action( 'gform_after_submission_2', 'add_points', 10, 2 );
    function add_points( $entry, $form ) {
     
        //getting points
        $points_to_add = rgar( $entry, '5' );
    	
    	// Set user I used a single line text in gravtiy forms and put {user:ID} in the default category. Then hid the field. 
    	$user = rgar( $entry, '11' );
    
    	//default points
        mycred_add( 'adding points', $user, $points_to_add, 'Points for being awesome!' ); 
           //custom points. In this case I am using quiz_scored as the addition type as I have badges set up for this. You can use your own, or pick one already in use. 
    	mycred_add( 'quiz_scored', $user, $points_to_add, 'Points for being awesome!', $ref_id, $ref_id, 'custom_point_type' );
    }
Viewing 3 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic.

11