Skip to:
Content
Pages
Categories
Search
Top
Bottom

Default Tab depending on Friendship


  • Nahum
    Participant

    @nahummadrid

    I’ve started reading threads about the BP_DEFAULT_COMPONENT & define( ‘BP_DEFAULT_COMPONENT’, ‘profile’ ); which I get and it works but I was wondering if anyone knows of a plugin or of a way to add a check to see if the member is a friend or follower.

    I’m thinking of doing something like;

    if the user is a friend
    show Activity as default tab
    if not
    show Profile as default tab

    the more I think about it, the more it sounds like a privacy plugin but I haven’t seen anything like that as a feature of current privacy plugins.
    I guess this is similar to FB behavior when looking at profile pages. I guess the privacy element would require to hide all but profile tab if not a friend and I don’t know that I need that right now. just switching between tabs I think is enough for what I’m thinking.

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

  • 4ella
    Participant

    @4ella

    Very nice and interesting idea , hope you will find a solution


    Brajesh Singh
    Participant

    @sbrajesh

    Put this code in bp-custom.php

    `

    add_action(“bp_setup_globals”,”my_default_tab”,8);

    function my_default_tab(){
    global $bp;
    global $displayed_user_id;

    $current_user_id=get_current_user_id();
    if(!$displayed_user_id)
    return;//if it is not profile return

    //a fix for table name before querying friendship
    $bp->friends->table_name = bp_core_get_table_prefix() . ‘bp_friends’;//a fix for friend check, because the table names are initialized too late

    if(friends_check_friendship( $current_user_id, $displayed_user_id ))
    define(“BP_DEFAULT_COMPONENT”,BP_ACTIVITY_SLUG);
    else
    define(“BP_DEFAULT_COMPONENT”,BP_XPROFILE_SLUG);
    }

    `
    That should do it.


    Nahum
    Participant

    @nahummadrid

    @sbrajesh Now…that! is awesome.


    Nahum
    Participant

    @nahummadrid

    @sbrajesh
    to account for your own profile? would it be good to do this to this line:

    `if(friends_check_friendship( $current_user_id, $displayed_user_id ) || bp_is_my_profile())`


    Brajesh Singh
    Participant

    @sbrajesh

    No, That should not work. Reason, the $bp->displayed_user object is not initialized at the moment we are making changes.
    Instead check $displayed_user_id==$current_user_id


    Nahum
    Participant

    @nahummadrid

    bp_is_my_profile seemed to work but I’ll take your advice for sure. thanks!


    Nahum
    Participant

    @nahummadrid

    @sbrajesh this stopped working in 1.5.1, any ideas?


    Nahum
    Participant

    @nahummadrid

    Any ideas why is not working with 1.5.1

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Default Tab depending on Friendship’ is closed to new replies.
Skip to toolbar