Created
June 4, 2021 00:27
-
-
Save sc0ttkclark/fae77be49d696531fe52650ba653004a to your computer and use it in GitHub Desktop.
Use a filter to adjust the content based on Membership Level for the User Page that is created with PMPro and the User Pages Add-On.
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 | |
/* | |
* When the user page is created, add some content based on membership level. | |
* | |
* @param array $postdata The data to use when saving the new user page. | |
* @param WP_User $user The user the page is being created for. | |
* @param object $level The membership level object. | |
* | |
* @return array The data to use when saving the new user page. | |
*/ | |
function my_pmpro_user_page_purchase_postdata_content( $postdata, $user, $level ) { | |
if ( 1 === $level->ID ) { | |
// Show specific content for this membership level. | |
$postdata['post_content'] = "<p>Thank you for using our site.</p> | |
<p>You are a SILVER member, thanks for joining!</p> | |
<p>Here are helpful links:</p> | |
<ul style='margin-bottom: 3em;'> | |
<li><a href='" . esc_url( home_url() ) . "'>Homepage</a></li> | |
<li><a href='" . esc_url( home_url( '/members/') ) . "'>Members Area</a></li> | |
<li><a href='" . esc_url( home_url( '/contact/') ) . "'>Contact Us</a></li> | |
</ul> | |
"; | |
} elseif ( 2 === $level->ID ) { | |
// Show specific content for this membership level. | |
$postdata['post_content'] = "<p>Thank you for using our site.</p> | |
<p>You are a GOLD member, thanks for joining!</p> | |
<p>Here are helpful links:</p> | |
<ul style='margin-bottom: 3em;'> | |
<li><a href='" . esc_url( home_url() ) . "'>Homepage</a></li> | |
<li><a href='" . esc_url( home_url( '/members/') ) . "'>Members Area</a></li> | |
<li><a href='" . esc_url( home_url( '/gold-rewards/') ) . "'>GOLD Rewards</a></li> | |
<li><a href='" . esc_url( home_url( '/contact/') ) . "'>Contact Us</a></li> | |
</ul> | |
"; | |
} | |
return $postdata; | |
} | |
add_filter( 'pmpro_user_page_purchase_postdata', 'my_pmpro_user_page_purchase_postdata_content', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment