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 | |
// --------------------------------------------- | |
// FORCE THE DISPLAY_NAME USER VARIABLE TO BE THEIR FIRST NAME | |
// --------------------------------------------- | |
function rol_set_display_name( $display_name ) { | |
// New user via WP Admin > Users > Add New | |
// Edit user's name via WP Admin > Users > edit user | |
// Edit user's name via WP Admin > MemberPress > Members > edit user | |
if ( isset( $_POST['first_name'] ) ) { |
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 | |
// 1) User purchases and payment is complete | |
function capture_completed_transaction($txn) { | |
//It's possible this could be a recurring transaction for a product the user is already subscribed to so probably use a user meta field described below | |
$user = new MeprUser($txn->user_id); //A MeprUser object | |
$membership = new MeprProduct($txn->product_id); //A MeprProduct object | |
$users_memberships = $user->active_product_subscriptions('ids'); //An array of membership CPT ID's | |
//Here you may want to grab a user meta field of your own creating and check to see if the user is already subscribed to this membership or not | |
//If not, then push them to your 3rd party application and update the user meta field |
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 | |
//PASTE THIS CODE IN A PLUGIN LIKE My Custom Functions (RECOMMENDED) OR IN YOUR THEME'S functions.php FILE | |
//THIS ASSUMES YOU HAVE THE GOOGLE ANALYTICS JAVASCRIPT INCLUDED ALREADY | |
function echo_ga_tracking_script() { | |
if(isset($_GET['membership']) && isset($_GET['trans_num'])) { | |
$txn = MeprTransaction::get_one_by_trans_num($_GET['trans_num']); | |
if(isset($txn->id) && $txn->id > 0) { | |
//Echo the script to the HTML <head> | |
?> |
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 | |
// Paste the code below into a plugin like Code Snippets (run on front end snippet type) | |
function leave_one_country($countries, $prioritize_my_country) { | |
return array( | |
'DE' => _x('Germany', 'ui', 'memberpress') | |
); | |
} | |
add_filter('mepr_countries', 'leave_one_country', 10, 2); |
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 | |
$user = MeprUtils::get_currentuserinfo(); | |
$sub_user_ids = array(); | |
if($user !== false) { | |
$transactions = $user->active_product_subscriptions('transactions'); | |
if(!empty($transactions)) { | |
foreach($transactions as $txn) { | |
if(($sub = $txn->subscription()) !== false) { |
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_disable_auto_login($auto_login, $membership_id, $mepr_user) { | |
return false; | |
} | |
add_filter('mepr-auto-login', 'mepr_disable_auto_login', 3, 3); |
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 | |
//Capture a new member signup. Only ever triggers once for each new member. | |
//Does not trigger for exising members who have subscribed to a Membership before. | |
// | |
//The user may not be logged in when this is called | |
//as it is triggered when a user is added over the REST API, | |
//and also when a user is added from the dashboard (MemberPress -> Members -> Add New) | |
function mepr_capture_new_member_signup_completed($event) { | |
$user = $event->get_data(); | |
$txn_data = json_decode($event->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 | |
function nua_allow_user_if_membership($errors) { | |
$allowed_memberships = array(123,321,789,987); // CHANGE THIS | |
if(!is_user_logged_in()) { | |
if(in_array((int)$_POST['mepr_product_id'], $allowed_memberships)) { | |
$_REQUEST['action'] = 'createuser'; //Set this so "New User Approve" plugin will not limit the subscriber | |
} | |
} |
NewerOlder