Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sc0ttkclark/fae77be49d696531fe52650ba653004a to your computer and use it in GitHub Desktop.
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.
<?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