Skip to content

Instantly share code, notes, and snippets.

@dwanjuki
Last active March 9, 2026 15:34
Show Gist options
  • Select an option

  • Save dwanjuki/10106e1fb96bcb4f1e54d0595b3b0158 to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/10106e1fb96bcb4f1e54d0595b3b0158 to your computer and use it in GitHub Desktop.
Hide BuddyPress activity from members pending approval.
<?php
/**
* Hide BuddyPress activity from members pending approval.
*
* 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/
*/
/**
* Redirect pending members from the Activity page to Profile page.
*/
function my_bp_activity_page_redirect_pending_pmpro_members() {
if ( ! class_exists( 'PMPro_Approvals' ) || ! function_exists( 'bp_is_activity_component' ) ) {
return;
}
// If accessing the BuddyPress activity component.
if ( bp_is_activity_component() ) {
// If member is not approved.
if ( ! PMPro_Approvals::isApproved() ) {
// Get BP profile URL and redirect there.
$current_user_id = get_current_user_id();
$edit_profile_url = trailingslashit( bp_core_get_user_domain( $current_user_id ) ) . 'profile/';
wp_redirect( $edit_profile_url );
exit;
}
}
}
add_action( 'template_redirect', 'my_bp_activity_page_redirect_pending_pmpro_members' );
/**
* Hide BuddyPress Activity tabs/links from pending members.
*/
function my_bp_remove_activity_tab_for_pending_pmpro_members() {
global $bp;
if ( ! class_exists( 'PMPro_Approvals' ) ) {
return;
}
// If member is not approved.
if ( ! PMPro_Approvals::isApproved() ) {
// Remove the main Activity tab.
bp_core_remove_nav_item( 'activity' );
// Remove the sub‑nav items under Activity.
if ( isset( $bp->bp_options_nav['activity'] ) ) {
unset( $bp->bp_options_nav['activity'] );
}
}
}
add_action( 'bp_setup_nav', 'my_bp_remove_activity_tab_for_pending_pmpro_members', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment