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?
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.
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.
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 !