This file contains hidden or 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 // do NOT copy this line, copy from below this line | |
// Add this code below to your PMPro Customizations plugin | |
// http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
/** | |
* This filter hook is applied to the translated text by the internationalization function that handle contexts (_x(), _ex(), esc_attr_x() and esc_html_x()). | |
* | |
* @param string $translated | |
* @param string $text |
This file contains hidden or 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 certain downloadable products to Paid Memberships Pro members for free. | |
* Adjust the code to your needs and to match your WooCommerce Product IDs and Membership Level IDs. | |
* Follow this guide to add the code to your WordPress website - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function free_download_product_for_members( $discount_price, $level_id, $original_price, $product ) { | |
$allowed_free_products = array( 58, 59, 100, 300, 501); // Adjust this with the WooCommerce Product ID's that are allowed to be discounted. |
This file contains hidden or 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 from below here... | |
/** | |
* Add username to PayPal order description. | |
* Equivalent for Authorize.net also included, but commented out. | |
*/ | |
function my_pmpro_custom_level_description_add_username( $description, $level_name, $order, $site_name ) { | |
//Initialize $username |
This file contains hidden or 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 from below here | |
/** | |
* Will redirect users without a $required_levels away from pages where the request uri begins with '/places/'. | |
* Useful to lock down the archive page and CPTs of GeoDirectory plugin. | |
*/ | |
function my_pmpro_redirect_places() { | |
$request_uri_to_redirect = '/places/'; |
This file contains hidden or 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 from below here | |
/* | |
* Prevents a cancellation email from being set if the user | |
* was assigned a new membership level during the cancellation | |
* process. | |
*/ | |
function my_pmpro_disable_incorrect_cancellation_emails($recipient, $email) |
This file contains hidden or 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 a custom column to the Memberships > Members admin page for a user field | |
* added via Register Helper using a WP List Table filter (PMPro v2.2+). | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ |
This file contains hidden or 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 from below here | |
/** | |
* Give site admins access to PMPro BuddyPress content, even without membership level | |
*/ | |
function my_pmpro_bp_give_admins_access( $can, $check, $user_id ) { | |
if( current_user_can( 'manage_options' ) ){ |
This file contains hidden or 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 | |
/** | |
* Always send the checkout_free confirmation email | |
* when changing a user's level in the admin dashboard. | |
*/ | |
function my_send_pmpro_confirmation_emails_from_dashboard( $level_id, $user_id, $cancel_level_id ) { | |
// If we're not in the dashboard, this is probably a checkout on the frontend | |
if ( ! is_admin() ) { | |
return; | |
} |
This file contains hidden or 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 my_login_redirect( $redirect, $request, $user ) { | |
if ( ! empty( $request ) ) { | |
remove_filter('login_redirect', 'pmpromh_login_redirect', 10, 3); | |
remove_filter('login_redirect','pmpro_login_redirect', 10, 3); | |
return $redirect; | |
} | |
} | |
add_action( 'login_redirect', 'my_login_redirect', 5, 3 ); |
This file contains hidden or 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 from below here | |
/** | |
* Automatically applies discount code for users switching from a level in a set of given levels. | |
* Useful for giving discounts to members upgrading their memberships. | |
* To use, make sure to update the first 2 variables in each function. | |
*/ | |
function my_pmpro_automatic_discount_application() { |