Skip to:
Content
Pages
Categories
Search
Top
Bottom

Dynamic Redirect, htaccess? ugh, custom profile tabs.


  • wolfpup64
    Participant

    @wolfpup64

    I posted up on this a little while ago, and danbp was a boss and helped me out, and I thought I could get it to work, but the end fix ended up unfortunately not really fixing the problem.

    I’m having difficulty with a profile tab that is supposed to link to a separate forums profile (wpForo) via a dynamic link that recognizes the displayed user’s page. danbp set me up with something like the below, I changed a bit to make it work better…

    function tab_custom_link_to_page() {
    
    	if ( bp_is_page( 'BP_MEMBERS' ) ||  bp_is_activity_component() || bp_is_profile_component () || bp_is_groups_component () || bp_is_notifications_component () || bp_is_messages_component () || bp_is_settings_component () || bp_is_following_component () || bp_is_followers_component () ) {
    		
    		$link = bp_get_root_domain() . '/community/profile/'. bp_get_displayed_user_username();
    		echo '<li><a href="'. $link .'">Community</a></li>'; 
    	}  
    }
    add_action( 'bp_member_options_nav', 'tab_custom_link_to_page', 10 );

    but I couldnt change the location of the tab, using code or BuddyBoss Reorder Tabs plugin, which is an issue because the theme I’m using (BuddyBoss Boss.) hides the tabs at the end under a clickable “…”. I spoke to someone at BuddyBoss and they told me I wouldn’t be able to move the tab unless it was registered as a “bp_core_new_nav_item( array(“, which requires an array like:

    function add_communityprofile_tab() {
    	global $bp;	
    	bp_core_new_nav_item( array(
    		'name'                  => 'Community',
    		'slug'                  => 'community',
    		'parent_url'            => $bp->displayed_user->domain,
    		'parent_slug'           => $bp->profile->slug,		
    		'position'              => 200,
    		'default_subnav_slug'   => 'community'
    	) );
    }
    add_action( 'bp_setup_nav', 'add_communityprofile_tab', 100 );

    which works fine until I have to link it, apparently I can’t use the tab array/slug thing to reach a dynamic link without the same “$bp->displayed_user->domain”. The link I’m trying to reach is currently at:

    http://localhost/wordpress/community/profile/*displayeduser*/

    from:

    http://localhost/wordpress/users/*displayeduser*/

    If nobody has any helpful suggestions otherwise, I’m thinking the best route might be to have the page

    http://localhost/wordpress/users/*displayeduser*/community/

    redirect to

    http://localhost/wordpress/community/profile/*displayeduser*/

    via a dynamic redirect…I’m trying to figure out how to do that.

    If anyone has any helpful advice it would be super appreciated. My boss wants me to take the site live this week and I think I’m just about there…aside from this huge disconnect between the two separate user profiles…not too bad for someone who has barely any idea what they’re doing. but yeah, sorry for the super long post. thanks for reading and hopefully you can throw me a line.

    – Andrew

Viewing 2 replies - 1 through 2 (of 2 total)

  • modemlooper
    Moderator

    @modemlooper

    bp_core_new_nav_item()

    bp_core_new_nav_item doesn’t need

    ‘parent_url’ => $bp->displayed_user->domain,
    ‘parent_slug’ => $bp->profile->slug,

    remove those.

    create a function to redirect

    function my_redirect() {
        if ( 'community' === bp_current_component() ) {
            bp_core_redirect( 'your link here );
        }
    }
    add_action( 'template_redirect', 'my_redirect' );

    wolfpup64
    Participant

    @wolfpup64

    Ah! It lives. I must’ve been looking at the wrong codex page, either way I would’ve been struggling with the whole redirect thing for a while haha. Thanks so much for your help man, I’ve been trying to figure this stuff out for a couple weeks now. These support forums really need a buy a beer button.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar