This file contains 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 | |
// Validate if user is over 18 years old | |
add_filter('mepr-validate-signup', 'validate_birthday_input'); | |
function validate_birthday_input($errors) { | |
$slug = 'mepr_birthday'; // CHANGE THIS TO MATCH THE SLUG OF YOUR BIRTHDAY FIELD | |
if(is_user_logged_in()) { return $errors; } | |
$then = strtotime($_POST[$slug]); | |
This file contains 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 | |
// Change number of courses per page on Classroom page | |
function num_posts_course_archive($query){ | |
if ($query->is_archive('mpcs_course')) { | |
$query->set('posts_per_page', 10); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts', 'num_posts_course_archive'); |
This file contains 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 | |
// Add shortcode for displaying membership price. We can use it like this: [membership_price id="123"] where id is membership ID | |
function display_membership_price($atts, $content) { | |
if(!isset($atts['id'])) { return; } | |
$mepr_options = MeprOptions::fetch(); | |
echo $mepr_options->currency_code_str . get_post_meta($atts['id'], '_mepr_product_price', true); | |
} | |
add_shortcode('membership_price', 'display_membership_price'); |
This file contains 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 | |
// This will set the expires at hour, minute, second to the same hour, minute, second when the user joined. | |
function update_txn_expires_at($txn, $old_txn = false) { | |
global $wpdb; | |
if(!isset($txn->id) || (int)$txn->id <=0 || $txn->expires_at == '0000-00-00 00:00:00') { return; } | |
$expires_at_ts = strtotime($txn->expires_at); | |
$created_at_ts = strtotime($txn->created_at); | |
This file contains 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 | |
function capture_mepr_payments($txn) { | |
if($txn->status == MeprTransaction::$confirmed_str) { | |
$sub = $txn->subscription(); // Get subscription object (if any) MeprSubscription | |
if(isset($sub->id) && $sub->id > 0) { | |
if($sub->trial && $sub->trial_amount <= 0.00) { | |
// Subscription has a free trial period defined by $sub->trial_days | |
} | |
else { |
This file contains 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 | |
//Copy lines below this, and paste into a "Run Everywhere" Snippet type in the Code Snippets plugin. | |
function make_coupon_mandatory($errors) { | |
if(!isset($_POST['mepr_coupon_code']) || $_POST['mepr_coupon_code'] === '') { | |
$errors[] = 'Sorry, coupon code is mandatory field.'; | |
} | |
return $errors; | |
} | |
add_filter('mepr-validate-signup', 'make_coupon_mandatory'); |
This file contains 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 | |
//Copy lines below this, and paste into a "Run Everywhere" Snippet type in the Code Snippets plugin. | |
function update_course_custom_type() { | |
global $wp_post_types; | |
if ( post_type_exists( 'mpcs-course' ) ) { | |
// exclude from search results | |
$wp_post_types['mpcs-course']->exclude_from_search = true; | |
$wp_post_types['mpcs-lesson']->exclude_from_search = true; | |
} | |
} |
This file contains 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
If you lock yourself out of your own dashboard via the Members plugin. | |
Open your wp_options table in PHPMyAdmin and search for the wp_user_roles row. | |
Set the following as wp_user_roles value to restore default WP Roles and Caps | |
a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_ |
This file contains 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 | |
// For non recurring | |
add_filter('mepr_stripe_payment_intent_args', function ($args) { | |
$args['statement_descriptor'] = 'Custom Descriptor'; // max 22 chars | |
return $args; | |
}); |
This file contains 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 | |
// IMPORTANT - Don't forget to change your email address on line #36 below - or you won't get the emails | |
// Copy/Paste the lines below this one (starting with line #5) into a plugin like Code Snippets (run everywhere snippet type) | |
function capture_deleted_users_and_email($user_id, $reassign_id = null) { | |
$user = new MeprUser($user_id); | |
$logged_in_user = MeprUtils::get_currentuserinfo(); | |
$logged_in_user_id = ($logged_in_user !== false) ? $logged_in_user->ID : ": Not Set"; | |
$logged_in_user_email = ($logged_in_user !== false) ? $logged_in_user->user_email : ": Not Set"; | |