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 away from 'normal' content to BuddyPress content restricted page. | |
* Requires the BuddyPress Integration to be installed - https://www.paidmembershipspro.com/add-ons/buddypress-integration/ | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_template_redirect_require_membership_access() { | |
if ( ! pmpro_has_membership_access() && ! bp_current_component() && ! is_archive() && ! is_home() && function_exists( 'pmpro_bp_redirect_to_access_required_page' ) ) { | |
pmpro_bp_redirect_to_access_required_page(); |
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 | |
/** | |
* Auto-populate user names for active members in a field drop-down. | |
* This will assume you are using a select field named "membership-list" | |
* The value of the select is the user's email and the label is set to the user's login name. | |
* Data Example: <option value="[email protected]">Test User</option> | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_auto_populate_members ( $tag, $unused ) { |
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 | |
/** | |
* Stop existing members from changing levels when purchasing a product on WooCommerce. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function woo_dont_apply_level_for_existing_members() { | |
if ( pmpro_hasMembershipLevel( '1' ) ) { | |
remove_action( 'woocommerce_order_status_completed', 'pmprowoo_add_membership_from_order' ); |
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 | |
/** | |
* Load custom CSS on checkoutpage for specific membership level in Paid Memberships Pro. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function load_css_for_level_checkout(){ | |
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
/** | |
* Autocomplete orders with only virtual products. | |
* From the 2nd edition of Building Web Apps with WordPress | |
* https://bwawwp.org | |
*/ | |
function autocomplete_virtual_orders($order_id) { | |
//get the existing order | |
$order = new WC_Order($order_id); | |
//assume we will autocomplete |
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 with level 1 from site.com/page-slug to the home page. | |
* Please adjust accordingly and add to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function redirect_member_from_page_x() { | |
if ( is_page( 'page-slug' ) && pmpro_hasMembershipLevel( 1 ) ) { | |
wp_redirect( home_url() ); //redirect to home page. Change home_url() to home_url( '/page-slug' ) to redirect to specific page. |
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 only show renewal date within 30 days or less than the members expiration. | |
* Add this code from line 7+ to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Visit www.paidmembershipspro.com for help. | |
*/ | |
function show_renewal_link_on_30_days( $r, $level ) { | |
if ( empty( $level->enddate ) ) { | |
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
/** | |
* Based on the Register Helper example. | |
* We've added a "buddypress" option for each field | |
* set to the XProfile name we used when setting up | |
* the fields in the BuddyPress extended profile. | |
* If the PMPro BuddyPress Add On is activated | |
* then the fields will be synchronized. | |
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/ | |
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/ | |
*/ |
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 | |
/** | |
* Assign a membership level based on product ID variation purchase. | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function add_membership_for_variation_pricing( $order_id ) { | |
global $wpdb, $pmprowoo_product_levels; | |
// quitely exit if PMPro isn't active |
NewerOlder