Forked from strangerstudios/pmpro-user-page-content-filter.php
Last active
July 8, 2021 17:19
-
-
Save kimwhite/5e16208b33a725422203798c499c63b9 to your computer and use it in GitHub Desktop.
Use a filter to adjust the content of the user page that is created with PMPro and the User Pages addon.
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 // do not copy this line. | |
/** | |
* When the user page is created, add some content. Add default content by Level. | |
* | |
* 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/ | |
*/ | |
function my_pmpro_user_page_purchase_postdata_content($postdata, $user, $level) | |
{ | |
if($level->ID == '1'){ | |
//update post content | |
$postdata['post_content'] = "<p>Thank you for using our site.</p> | |
<p>This is for level 1.</p> | |
<p>We got links:</p> | |
<ul style='margin-bottom: 3em;'> | |
<li><a href='" . home_url() . "'>Homepage</a></li> | |
<li><a href='" . home_url("/members/") . "'>Members Area</a></li> | |
<li><a href='" . home_url("/contact/") . "'>Contact Us</a></li> | |
</ul>"; | |
return $postdata; | |
} | |
if($level->ID == '2'){ | |
//update post content | |
$postdata['post_content'] = "<p>This is for level 2</p> | |
<p>This is some extra content for the user page.</p> | |
<p>We got links:</p> | |
<ul style='margin-bottom: 3em;'> | |
<li><a href='" . home_url() . "'>Homepage</a></li> | |
<li><a href='" . home_url("/members/") . "'>Members Area</a></li> | |
<li><a href='" . home_url("/contact/") . "'>Contact Us</a></li> | |
</ul>"; | |
return $postdata; | |
} | |
else{ | |
//update post content | |
$postdata['post_content'] = "<p>This is for Default Content no level</p> | |
<p>This is some extra content for the user page.</p> | |
<p>We got links:</p> | |
<ul style='margin-bottom: 3em;'> | |
<li><a href='" . home_url() . "'>Homepage</a></li> | |
<li><a href='" . home_url("/members/") . "'>Members Area</a></li> | |
<li><a href='" . 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