• Resolved ZaacWilliam

    (@omo9jatoja)


    Am trying to give out codes to my users once they fill a gravityform and submit,

    1) I’ll generate a code myself using automatic alpha numeric rands
    2) use a code to put in gravity form fora particular membership
    3.)
    4. I’ll then send the codes for the users using there mail submitted with the form

    The problem i have now is crating paid membership pro

    • This topic was modified 3 years, 2 months ago by ZaacWilliam.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi @omo9jatoja

    Thank you for reaching out.

    I don’t have a clear understanding of this request. Could you please elaborate on “The problem i have now is crating paid membership pro”. Are you having an issue creating a discount code within Paid Memberships Pro?

    Thread Starter ZaacWilliam

    (@omo9jatoja)

    I’m looking forward to always create/generate a discount code when some codes ….like below is fired

    $args = array(
            'discount_code' = 'hsfhgkkhj';
    	'level'      =  2,
    	'code_max' =  1
    );
    $discount_code = pmpro_create_new_discount_code( $args );
    
    if ( $discount_code !== false && ! is_wp_error( $discount_code ) ) {
    
    	// discount code will be created successfully after the code is fired! 
    
    }

    I need paid membership pro functionality like eg, : pmpro_create_new_discount_code( $args );

    • This reply was modified 3 years, 2 months ago by ZaacWilliam.
    • This reply was modified 3 years, 2 months ago by ZaacWilliam.
    Plugin Author Andrew Lima

    (@andrewza)

    Thanks for the feedback, you will need to use the following class to create a discount code – https://github.com/strangerstudios/paid-memberships-pro/blob/2138c26af6bf2fb5cc1a3511be27ed8e1264eef8/classes/class-pmpro-discount-codes.php#L3

    
    $discount_code = new PMPro_Discount_code();
    $discount_code->save();
    

    This would create an empty discount code and save it to the database. You may set the discount code object to have a specific price, as well as what levels they are for etc.

    If you need help with this customization further, please reach out to a local WordPress developer for assistance.

    I hope this helps get you started.

    Thread Starter ZaacWilliam

    (@omo9jatoja)

    good day, please can i get a code/snippets to validate if a discount is used or not and if not used redeem the code to its specific level !
    please it very urgent !

    am in need of the function because am using gravity forms for registration and i want user to select levels on the form while registering and also insert a discount code to a field which it will create the users and assign the user to the suitable level for the inserted code else if code is invalid user registration will then be decline !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PLEASE I NEED HELP CREATING A CUSTOM DISCOUNT CODE AFTER GRAVITYFORM SUBMISSION’ is closed to new replies.