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 | |
/** | |
* Set Display Name on Membership Checkout and for BuddyPress Name field. | |
*/ | |
function my_first_last_display_name( $user_id, $morder ) { | |
// Get user's first and last name. | |
$first_name = get_user_meta( $user_id, 'first_name', true ); | |
$last_name = get_user_meta( $user_id, 'last_name', true ); | |
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
/** | |
* Require Members to live in Canada to checkout for a specific level. | |
*/ | |
function my_pmpro_require_canada_level_8( $value ) { | |
global $pmpro_level; | |
$bcountry = $_REQUEST['bcountry']; | |
if ( ( $pmpro_level->id == '8' ) && ( $bcountry != 'CA' ) ) { | |
global $pmpro_msg, $pmpro_msgt; |
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
#Example SQL to duplicate restrictions for level ID 1 to also restrict for level ID 2 | |
INSERT IGNORE INTO wp_pmpro_memberships_pages (membership_id, page_id) | |
SELECT '2', page_id FROM wp_pmpro_memberships_pages WHERE membership_id = 1; |
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
#Example SQL to add restriction to all 'posts' for Level ID 2. Change level ID for your needs. | |
INSERT IGNORE INTO wp_pmpro_memberships_pages (membership_id, page_id) | |
SELECT 2, ID FROM wp_posts WHERE post_type = 'post'; |
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 | |
/** | |
* Remove or change the level cost for free levels. | |
*/ | |
function free_level_change_pmpro_level_cost_text( $text, $level ) { | |
if ( pmpro_isLevelFree( $level ) ) { | |
return ''; | |
} else { | |
return $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
<span class="pricecustomtext"> | |
<span class="standardcoupon"> | |
<span class="pricediscount"> | |
<span class="pricediscounttitle">62% OFF!</span> | |
<span class="pricediscountcoupon">Groupon Deal</span> | |
</span><br> | |
<span class="pricetotal"><span class="priceoriginal">$32</span>$12</span> | |
<span class="pricerenewal">Renews in 3 months at $32/quarter.<br> Cancel anytime.</span> | |
</span> | |
</span> |
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 | |
/** | |
* Modify the text of the login link in all membership checkout confirmation emails. | |
* | |
*/ | |
function my_pmpro_email_custom_login_link_text( $body, $email ) { | |
// Only filter checkout emails. | |
if ( strpos( $email->template, 'checkout' ) !== false ) { | |
// Change text "Log in to your membership account here:" to "Log in to get started:". | |
$body = str_replace( 'your membership account here', 'get started', $body ); |
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 return the post thumbnail (featured image) on restricted content when viewed by a non-member. | |
* | |
*/ | |
function hide_post_thumbnail_on_restricted_content( $html, $post_id, $post_image_id ) { | |
if ( function_exists( 'pmpro_has_membership_access' ) ) { | |
// Check if the user has access to the post. | |
$hasaccess = pmpro_has_membership_access( $post_id ); |
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 | |
/** | |
* Hide the 'gallery' CPT from searches and archives if membership is required to access. | |
* | |
*/ | |
function hide_gallery_events_filter_post_types( $post_types ) { | |
$post_types[] = 'gallery'; | |
return $post_types; | |
} | |
add_filter( 'pmpro_search_filter_post_types', 'hide_gallery_events_filter_post_types' ); |
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
/** | |
* Create random orders for all members. | |
* visit /wp-admin/?create_random_orders=1 to generate orders, then remove this code | |
* Warning, this can time out or slow your server if you have many members or a long timeframe. | |
*/ | |
function pmproc_create_random_orders() { | |
global $wpdb; | |
if ( empty( $_REQUEST['create_random_orders'] ) ) { | |
return; |