Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dwanjuki/f4ec00311749ef470def9e9d2bf34c25 to your computer and use it in GitHub Desktop.
Save dwanjuki/f4ec00311749ef470def9e9d2bf34c25 to your computer and use it in GitHub Desktop.
Redirect the PMPro Profile Edit and Password Reset pages to the user's BuddyPress Profile and Settings pages respectively
<?php
/**
* Redirect the PMPro Profile Edit and Password Reset pages
* to the user's BuddyPress Profile and Settings pages
*
* 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;
}
if ( is_page( $pmpro_pages['member_profile_edit'] ) ) {
$bp_profile_url = bp_loggedin_user_domain();
// Redirect the PMPro Change Password page to the BuddyPress Settings page
if( isset( $_GET['view'] ) && $_GET['view'] == 'change-password' ) {
$bp_settings_url = $bp_profile_url . bp_get_settings_slug();
wp_redirect( $bp_settings_url );
exit;
} else { // Redirect the PMPro Profile Edit page to the BuddyPress Profile Edit page
$bp_profile_edit_url = $bp_profile_url . bp_get_profile_slug() . '/edit';
wp_redirect( $bp_profile_edit_url );
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