Tagged: profile tabs
Hi, Is there a way to make a tab the default tab for members that are connected? In other words, if I’m not connected with someone the tab I see would be their profile, but once I’m connected with them the default tab I land on when visiting their page is a different tab that is not visible to uncommected members? Is this possible?
Hello Matthew,
Thank you for posting. Please try the following code and modify as per your requirement.
/** * Modify default tab. */ function buddydev_modify_default_tab() { if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( 'friends' ) ) { return; } // If both are friends set default tab to profile otherwise activity. if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) { define( 'BP_DEFAULT_COMPONENT', 'profile' ); } else { define( 'BP_DEFAULT_COMPONENT', 'activity' ); } } add_action( 'bp_setup_globals', 'buddydev_modify_default_tab', 15 );
Please let me know if it works or not.
Regards
RaviOk, thanks so much. Just to be sure, what php file should this be added to?
Hi Matthew,
Please put it in the bp-custom.php
https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/Regards
BrajeshHi, unfortunately I haven’t been able to get this to work. Here are the contents of my bp-custom file.
<?php
add_filter( ‘bp_auto_friendship_pro_enable_on_user_register’, ‘__return_true’ );
/**
* Modify default tab.
*/
function buddydev_modify_default_tab() {if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( ‘friends’ ) ) {
return;
}// If both are friends set default tab to profile otherwise activity.
if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
define( ‘BP_DEFAULT_COMPONENT’, ‘my-survey’ );
} else {
define( ‘BP_DEFAULT_COMPONENT’, ‘profile’ );
}
}add_action( ‘bp_setup_globals’, ‘buddydev_modify_default_tab’, 15 );
FYI – the auto connect users is working correctly. it is the default tab to display if two people are connecting that I can’t figure out.
Any help is greatly appreciated. Thanks, Matt
Hi, unfortunately I haven’t been able to get this to work. Here are the contents of my bp-custom file.
Sorry if this is a duplicate, not sure if the code would have been received because I didnt use the `.<?php add_filter( 'bp_auto_friendship_pro_enable_on_user_register', '__return_true' ); /** * Modify default tab. */ function buddydev_modify_default_tab() { if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( 'friends' ) ) { return; } // If both are friends set default tab to profile otherwise activity. if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) { define( 'BP_DEFAULT_COMPONENT', 'connections' ); } else { define( 'BP_DEFAULT_COMPONENT', 'profile' ); } } add_action( 'bp_setup_globals', 'buddydev_modify_default_tab', 15 );
FYI – the auto connect users is working correctly. it is the default tab to display if two people are connected that I can’t figure out.
Any help is greatly appreciated. Thanks, Matt
Hello Mathew,
It seems you are using BuddyBoss. What they are doing is overriding default component with nouveau option. Try the following code it will override default tab in nouveau settings.
/** * Modify default tab. */ function buddydev_modify_default_tab( $tab ) { if ( ! is_user_logged_in() || bp_is_my_profile() || ! bp_is_active( 'friends' ) ) { return $tab; } // If both are friends set default tab to profile otherwise activity. if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) { return 'friends'; } return 'profile'; } add_filter( 'bp_member_default_component', 'buddydev_modify_default_tab' );
Regards
RaviOk, so should this replace the previous code or be in addition to the previous code?
Actually that code gave me the following error. Parse error: syntax error, unexpected ‘ ‘ (T_STRING) in /home/customer/www/youryous.com/public_html/wp-content/plugins/bp-custom.php on line 10
Disregard the msg about the error. Still working on the issue.
You must be logged in to reply to this topic.