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
function my_custom_memberslist_order($sqlQuery) | |
{ | |
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>". | |
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>"; | |
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc')) | |
{ | |
$sort_order = $_REQUEST['enddate_sort']; | |
global $wpdb; |
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
/* | |
Use the short version of the 2Checkout signup form when checking out. | |
After installing and activating this, you'll also need to enable "SHORT_FORM" in your 2Checkout settings. | |
See: https://knowledgecenter.2checkout.com/Documentation/05Ordering/10Minimize_required_checkout_data | |
*/ | |
function my_pmpro_twocheckout_short_billing( $request_array ) { | |
$short_form = array( | |
"SHORT_FORM" => "1" | |
); | |
return array_merge( $short_form, $request_array ); |
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
// example of adding Javascript to run after the checkout button is clicked | |
function my_pmpro_js_on_submit() { | |
?> | |
<script> | |
jQuery(document).ready( function(){ | |
jQuery("#pmpro_form").submit( function(){ | |
alert("hello world!"); | |
}); | |
}); | |
</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 | |
/* | |
This code assumes you already have a 'myrole' custom role created. | |
Members signing up get the 'myrole' role in addition to any other roles they already have. | |
Members cancelling are given the subscriber role. | |
Admin users are ignored. | |
Usable with or without the PMPro Roles Add On. | |
*/ | |
function my_pmpro_after_change_membership_level($level_id, $user_id) | |
{ |
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
// customize the HTML/styling of links in PMPro-generated emails | |
function my_pmpro_change_email_link_styling( $data, $email ){ | |
/*--- An array of variable names. Change or add to this to style different links. | |
default options: 'invoice_link', 'levels_link', 'login_link' ---*/ | |
$links_to_change = array( 'invoice_link', 'login_link' ); | |
$newdata = []; | |
foreach( $data as $variable => $value ) { | |
if( in_array( $variable, $links_to_change) && strpos( $value, "http" ) !== 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 | |
/** | |
* Make PMPro MailChimp compatible with PMPro Email Confirmation | |
*/ | |
// Don't subscribe to MailChimp if user is not validated. | |
function my_pmproec_pmpro_after_change_membership_level($level_id, $user_id) { | |
if( function_exists('pmproec_isEmailConfirmationLevel') && pmproec_isEmailConfirmationLevel($level_id) ) { | |
$validation_key = get_user_meta($user_id, "pmpro_email_confirmation_key", 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
// change !!membership_cost!! email variable to refer to current level cost, only when checking out with paypal | |
function my_pmpro_email_membership_cost( $data, $email ) { | |
global $pmpro_levels; | |
// are we on the paypal ipnhandler page? if not, stop | |
if( !isset( $_SERVER["REQUEST_URI"] ) || ( strpos( $_SERVER["REQUEST_URI"], "/admin-ajax.php?action=ipnhandler" ) === false )) | |
return $data; | |
$level_id = $data['membership_id']; | |
$current_level = $pmpro_levels[$level_id]; | |
$data['membership_cost'] = pmpro_getLevelCost( $current_level ); |
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
/* | |
Restrict membership access based on parent category | |
*/ | |
function category_restrictions($hasaccess, $mypost, $myuser, $post_membership_levels) | |
{ | |
global $post, $current_user; | |
$categories = wp_get_post_categories($mypost->ID); | |
$restrict = 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
/* | |
Show sponsored seats on the account page in PMPro settings and on other selected pages. | |
Useful for multi-language sites that have different account pages per language. | |
Requires PMPro and Sponsored Seats Add On. | |
*/ | |
function my_pmprosm_the_content_account_page($content) | |
{ | |
global $post, $pmpro_pages, $current_user, $wpdb; | |
/* |
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
/* | |
Override the discount code given to sponsored members. | |
This recipe makes any sponsored members with level 2 expire in 2 days. | |
The 'discount_code' array supports the following attributes: | |
code_id, level_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit, | |
trial_amount, trial_limit, expiration_number, expiration_period | |
Make sure that strings in the _period values are wrapped in single quotes, e.g. 'expiration_period' => "'Year'" | |
*/ |