Last active
December 18, 2024 11:32
-
-
Save dwanjuki/1df3359d84ac0f705585377c2fe6b449 to your computer and use it in GitHub Desktop.
Add parent User Page link to top of Member Links list
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 | |
/** | |
* Add parent User Page link to top of Member Links list | |
* | |
* 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_member_links_top_parent_user_page() { | |
// bail if User Pages Add On inactive | |
if( ! function_exists( 'pmproup_get_page_for_user' ) ) { | |
return; | |
} | |
$user_page_id = pmproup_get_page_for_user(); | |
// Add the level IDs of levels with User Pages here | |
if( $user_page_id && pmpro_hasMembershipLevel( array( 2,3 ) ) ) { | |
$user_page_url = get_permalink( $user_page_id ); | |
echo '<li><a href="' . $user_page_url . '">Your Member Page</a></li>'; | |
} | |
} | |
add_action( 'pmpro_member_links_top', 'my_pmpro_member_links_top_parent_user_page' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment