Created
September 30, 2022 18:53
-
-
Save ideadude/534a6d3f8de389a6c08b1a412ecaa05d to your computer and use it in GitHub Desktop.
Some example code of how to create a PMPro membership level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Some example code of how to create a PMPro membership level. | |
* Uses the PMPro_Membership_Level class and save() method. | |
*/ | |
// Copy a level. | |
$level = new PMPro_Membership_Level( 1 ); // Pass the ID of the level to copy. | |
$level->id = $level->ID = null; // Clear out the ID, triggers insert on save. | |
$level->name = 'NewName'; // Update any property you want. | |
$level->save(); // Save. | |
$level_id = $level->id; // The id AND ID properties are updated on save. | |
// Create a level from scratch. | |
$level = new PMPro_Membership_Level(); | |
$level->name = 'Fan'; | |
$level->initial_payment = '10.00'; | |
$level->description = 'New description.'; | |
$level->recurring = 'yes'; | |
$level->billing_amount = '10.00'; | |
$level->cycle_number = 1; | |
$level->cycle_period = 'Month'; | |
$level->save(); | |
$level_id = $level->id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment