Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active April 13, 2021 18:29
Show Gist options
  • Save strangerstudios/d52f0e767d5fe543ee71 to your computer and use it in GitHub Desktop.
Save strangerstudios/d52f0e767d5fe543ee71 to your computer and use it in GitHub Desktop.
Use a filter to adjust the page template of the user page that is created with PMPro and the User Pages addon.
<?php
/*
When the user page is created, set the page template.
*/
function my_pmpro_user_page_purchase_postdata_template($postdata, $user, $level)
{
//update page template based on level
if($level->ID == '1')
{
$postdata['page_template'] = "level-1-template.php";
}
elseif($level->ID == '2')
{
$postdata['page_template'] = "level-2-template.php";
}
else
{
$postdata['page_template'] = "level-other-template.php";
}
return $postdata;
}
add_filter("pmpro_user_page_purchase_postdata", "my_pmpro_user_page_purchase_postdata_template", 10, 3);
?>
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Setting Default Page Content or Page Template with the User Pages Add On" at Paid Memberships Pro here: https://www.paidmembershipspro.com/setting-the-default-page-content-or-page-template-with-the-user-pages-add-on/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment