Forked from kimcoleman/my_pmpro_buddypress_profile_template_redirect.php
Last active
July 4, 2024 08:11
-
-
Save kimwhite/847177adcca2523c630990ded1a69d81 to your computer and use it in GitHub Desktop.
Redirect the Membership Account page to the user's BuddyPress Profile.
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 | |
/** | |
* This recipe Redirect the Profile Edit page to the user's BuddyPress Profile. | |
* | |
* 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_buddypress_profile_template_redirect() { | |
global $pmpro_pages; | |
// Make sure PMPro is active. | |
if ( empty( $pmpro_pages ) ) { | |
return; | |
} | |
// Make sure BuddyPress is active. | |
if ( ! function_exists( 'bp_loggedin_user_domain' ) ) { | |
return; | |
} | |
// Redirect the Membership Account page to the bbPress User Profile. | |
if ( is_page( $pmpro_pages['member_profile_edit'] ) ) { | |
wp_redirect( bp_loggedin_user_domain() ); | |
exit; | |
} | |
} | |
add_action( 'template_redirect', 'my_pmpro_buddypress_profile_template_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment