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 | |
/** | |
* Redirect non-members (including logged-in non-members) away from restricted pages and to home page. | |
* This allows non-members to access Paid Memberships Pro checkout/levels pages as well as the default WordPress login page. | |
* | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_redirect_non_members_example() { | |
global $pmpro_pages; |
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 change the user's membership level if the user selects 'lessthan2000' on th custom field. | |
* Adjust this code to match your needs. Please note that if the initial level checking out is free, | |
* and you want to assign to a paid level depending on field selected, you may need to adjust the new level's price to $0 or ensure both levels are free or paid. | |
* | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmprorh_init() |
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 | |
/** | |
* Give "All Access" to PMPro Series for specific membership level. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function open_series_to_specific_level($hasaccess, $thepost, $theuser, $post_membership_levels) { | |
// Bail if the user already has access to a post/page. | |
if ( $hasaccess ) { |
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 this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
function adjusting_the_pmpro_levels_array( $levels ) { | |
if( !pmpro_hasMembershipLevel() ) { | |
unset( $levels[1] ); // hide premium level for non-members. | |
}else{ | |
unset( $levels[2] ); // hide free level for members. |
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 redirect members from Page A to Page B. Non-members will be able to access Page A. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_template_redirect_members() { | |
if ( is_page('join') && pmpro_hasMembershipLevel() ) { | |
wp_redirect(home_url( '/my-page-slug' ) ); | |
exit; | |
} |
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 | |
// Adjusted from https://www.paidmembershipspro.com/give-users-a-default-membership-level-at-registration/ | |
//Disables the pmpro redirect to levels page when user tries to register | |
add_filter("pmpro_login_redirect", "__return_false"); | |
function my_pmpro_default_registration_level($user_id) { | |
$level = pmpro_getLevel( 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 | |
/** | |
* Copy this code (below) into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmprorh_init() | |
{ | |
//don't break if Register Helper is not loaded | |
if(!function_exists( 'pmprorh_add_registration_field' )) { | |
return 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
/* | |
If we 404, and the slug matches a discount code, redirect | |
Add this code to a custom plugin | |
*/ | |
function my_pmpro_pre_handle_404($preempt, $wp_query) { | |
global $wpdb; | |
//bail if PMPro is not installed | |
if(empty($wpdb->pmpro_discount_codes_levels)) |
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 | |
/** | |
* Show the user's expiration date, or their next payment date. | |
* Show the user's previously expired date if they were cancelled, expired or cancelled by an admin. | |
* If none of thhe above is found, the string 'nothing found' will be returned. | |
*/ | |
function my_show_user_enddate(){ | |
if ( is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel() ){ |
NewerOlder