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 add_custom_role( $bbp_roles ) { | |
$bbp_roles['basic_member_role'] = array( | |
'name' => 'Basic Member', | |
'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants | |
); | |
return $bbp_roles; | |
} |
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_action('avada_after_content', function() { | |
global $post; | |
if(class_exists('MeprRule') && MeprRule::is_locked($post)) { | |
$unauth_message = (class_exists('MeprRulesCtrl') ? MeprRulesCtrl::unauthorized_message($post) : ''); | |
echo do_shortcode($unauth_message); | |
?> | |
<script> |
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 add_optin_status($user) { | |
if(isset($_POST['meprconvertkit_opt_in'])) { | |
update_user_meta($user->ID, 'mepr_convertkit_optin_status', true); | |
} else { | |
update_user_meta($user->ID, 'mepr_convertkit_optin_status', false); | |
} | |
} | |
add_action('mepr-signup-user-loaded', 'add_optin_status', 11); |
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 mepr_validate_emails_signup($errors) { | |
$allowed_words = array('university'); // ADD ALLOWED WORDS HERE SEPARATED BY COMMAS. | |
$email = isset($_POST['user_email']) ? trim($_POST['user_email']) : ''; | |
$is_allowed = false; | |
// If email is empty for some reason or the membership shouldn't be validated, then just don't do anything. | |
if($_POST['mepr_product_id'] != 123 || empty($email)) { | |
return $errors; |
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 mepr_restrict_email_domains($errors) { | |
# Allowed email domains. | |
$allowed_email_domains = array('gmail.com', 'hotmail.com'); | |
$email_address = isset($_POST['user_email']) ? trim($_POST['user_email']) : ''; | |
# Don't bother validating if the email is empty. | |
if(empty($email_address)) { |
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 mepr_validate_username_length($errors) { | |
$username = isset($_POST['user_login']) ? trim($_POST['user_login']) : ''; | |
# Don't bother validating username if isn't present. | |
if(!$username) { | |
return $errors; | |
} |
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 cleanup_abandoned_signups($event) { | |
$txn = $event->get_data(); | |
$user = $txn->user(); | |
// Count complete transactions and non-complete transactions | |
$user_incomplete_txns = $user->transactions('`status` != "complete"'); | |
$user_complete_txns = $user->transactions('`status` = "complete"'); |
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 subscription_stopped_func($event) { | |
$sub = $event->get_data(); | |
$latest_txn = $sub->latest_txn(); | |
if ($sub->in_trial() && $latest_txn) { | |
// Set transaction's expiration date to yesterday. Effectively revokes their membership access. | |
$latest_txn->expires_at = MeprUtils::ts_to_mysql_date(time() - MeprUtils::days(1)); | |
$latest_txn->store(); |
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 | |
// Attach a phone number custom field when creating a Stripe Customer object. | |
// Replace mepr_phone_number with the actual slug of the phone number custom field in MemberPress. | |
function mepr_stripe_customer_extended_args($args, $user) { | |
$phone_number = trim(get_user_meta($user->ID, 'mepr_phone_number', true)); | |
if(!empty($phone_number)) { | |
$args['phone'] = $phone_number; | |
} |