Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_get_displayed_user_nav'

Viewing 21 results - 76 through 96 (of 96 total)
  • Author
    Search Results
  • Sandra l***
    Participant

    @ghostchild

    (appended here so that other participants can read the answer)

    In reply to your message saying that you still don’t see the tab in the subnav, I could be wrong but I would be inclined to think that your problem is not caused by the WP/BP versions (I am running the latest ones) but by the theme you are using.

    The “Events” nav is posted in the member profile through this call (in bp-events.php)

    /* Add ‘Events’ to the main navigation */
    bp_core_new_nav_item( array( ‘name’ => __(‘Events’, ‘bp-events’), ….. [stuff removed here]

    In order for this to work, your theme (wp-contentthemesyour-theme-herememberssinglehome.php) should contain this call in the “right” place

    bp_get_displayed_user_nav()

    e.g. If I take this line away from my theme (I decided to turn a regular WP theme into a BP compliant theme thanks to BuddyPress Template Pack), then the “Events” tab no longer shows up (and a few others disappear too).

    So you might want to verify your theme. Is it truly BP-compliant?

    sicksight
    Participant

    Your Code worked, but disables all navigations (adminbar….).
    I will remove the calls in my child theme, because it is the easyest way!

    Thanks for information guys! :)

    r-a-y
    Keymaster

    You can’t remove it as an action, since bp_get_displayed_user_nav() is a template tag and not an actionable item.
    If you’re using a child theme, remove the calls to bp_get_displayed_user_nav() or try hiding the menu via CSS.

    *Edit – Just thought of a sneaky way of doing this.

    Add the following to your theme’s functions.php:
    http://buddypress.pastebin.com/90L4iKve

    modemlooper
    Moderator

    the other fix is to change the function in the BP functions file. You’d have to keep track of that change on upgrades to BP. I still think you can remove it via remove_action.

    @r-a-y can you help at all?

    sicksight
    Participant

    Yes, I could do this, but then I must update my code after every plugin update (gallery, … )… When there is no remove_action possible, I must remove the line in the theme files…

    modemlooper
    Moderator

    Why not just remove the code directly from the template file?

    sicksight
    Participant

    Hey @modemlooper ! ;)

    Thanks for your reply, but it doesn´t work… To remove the action bp_get_displayed_user_nav(), I need the hook to which the function to be removed is hooked.
    https://codex.wordpress.org/Function_Reference/remove_action

    I think bp_get_displayed_user_nav()… isn´t hooked anywhere! :(

    Edit: Need a function like replace_action( $function_to_replace, $function_to_add, $priority, $accepted_args )! :D :D Like str_replace in php, or something!^^

    modemlooper
    Moderator

    remove_action( ‘bp_get_displayed_user_nav’ );

    Should be that to remove an action.

    https://codex.buddypress.org/how-to-guides/modifying-the-buddypress-admin-bar/

    #84244
    Jeff Sayre
    Participant

    Your welcome! I’m glad you got it to work.

    #84224
    Justin Frydman
    Participant

    @Jeff indeed it’s working now: Here is my bp-custom.php for others: http://pastie.org/1030176

    I think it wasn’t working because I had adjusted the do_action() function from within my function to do_action( ‘my_friends_setup_nav’); and I guess it needs to be left as do_action( ‘friends_setup_nav’);

    Thanks for all your help Jeff!

    #84223
    Justin Frydman
    Participant

    @Jeff you copied it in as my_friends_setup_nav()? Can you post your function please?

    #84221
    rich! @ etiviti
    Participant

    what about removing and re-adding just the subnav? (or getting a bit hackery and editing $bp->bp_options_nav array)

    #84220
    Jeff Sayre
    Participant

    Hum. That is odd. I copied the friends_setup_nav() into bp-custom.php, just like you did, and made one minor change to the outputted text so that I would know if it took. I altered the priority as indicated above, and it worked without issue.

    I would suggest that you first get the override working as I did before you try more complex output manipulation. Once you know that it is working, you can then move on to customizing the output. I would guess that there is something else in your custom code output that is causing this not to work. Have you checked PHP’s error logs?

    Also, make sure that you are using the default BuddyPress theme and no 3rd-party plugins. Distill your operating environment down to the least common denominator when trying to adjust the output of core files. That way, once you get things working as you like, if you have issues when switching to a custom theme and/or activating a 3rd-party plugin, that it is more then likely some conflict with those items.

    #84198
    Justin Frydman
    Participant

    Hey Jeff,

    Yeah I had tried that already (tried 99 etc…) and nothing seems to work. Thanks for trying though, really do appreciate the time.

    I decided to take another route and override the $bp global in my functions.php

    $disp_user = $bp->displayed_user->id;
    if( bp_friend_get_total_requests_count($disp_user) > 0) {
    $bp->bp_nav .= ‘(‘.bp_friend_get_total_requests_count($disp_user).’)‘;
    }

    This doesn’t really allow for the customization I want, but I guess it will have to do for now.

    #84217
    Jeff Sayre
    Participant

    Okay, so I quickly ran WP Hook Sniffer and saw that the remove_action function does not get fired because when it is invoked, the function friends_setup_nav has not yet been added via the add_action function. Furthermore, the add_action request in your bp-custom.php file is invoked before the add_action request hooked to friends_setup_nav(). So, whereas your custom navigation code is being triggered, it is quickly replaced with the default, core friends navigation code in friends_setup_nav().

    The simple solution is to set the priority of your custom function to something greater than 10. Don’t even bother with the remove_action function as it will never work at this point in code execution.

    add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’, 11 );

    That should work!

    #84216
    Justin Frydman
    Participant

    Thanks for having a look Jeff, however it didn’t help. I simply want to edit some HTML that is generated in a tab and it’s a total nightmare. Besides the fact that I wish this was generated in a template since it generates HTML, I just cannot seem to override this function: friends_setup_nav() located in bp-friends.php (line 87).

    Since that function adds it’s own action do_action( ‘friends_setup_nav’); I’m assuming I can remove it and add my own in it’s place but it doesn’t work.

    Even if I do install that plugin and find when it is fired, how does that help me? Does it just change how or where I call remove_action?

    Should I be trying to hook into something else?

    #84215
    Jeff Sayre
    Participant

    I have not looked at your pasted code. But you are correct in stating that bp-custom.php loads prior to the accessory core BP files. I’d suggest the following tweaks:


    remove_action( ‘bp_setup_nav’, ‘friends_setup_nav’, 5);
    add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’);

    Basically, hooks are defaulted to a priority of 10. So, you want to make sure that friends_setup_nav is removed before your custom my_friends_setup_nav() is added.

    This is just a quick stab at guessing the proper hook firing sequence. So, if this does not work, I suggest installing my WordPress Hook Sniffer plugin.

    #84211
    Justin Frydman
    Participant

    Well,

    I tried remove_action on the function I found that I want to customize, but it doesn’t work apparently because bp-custom.php is being loaded before bp-friends. I tried this in my theme’s functions.php as well, but it still does not work. What am I doing wrong?

    /***
    * Create custom functions for buddypress so updates do not override customizations
    */

    function my_friends_setup_nav() {
    global $bp;

    /* Add ‘Friends’ to the main navigation */
    bp_core_new_nav_item( array( ‘name’ => sprintf( __( ‘Friends (%d)2222′, ‘buddypress’ ), friends_get_total_friend_count() ), ‘slug’ => $bp->friends->slug, ‘position’ => 60, ‘screen_function’ => ‘friends_screen_my_friends’, ‘default_subnav_slug’ => ‘my-friends’, ‘item_css_id’ => $bp->friends->id ) );

    $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . ‘/’;

    /* Add the subnav items to the friends nav item */
    bp_core_new_subnav_item( array( ‘name’ => __( ‘My Friends’, ‘buddypress’ ), ‘slug’ => ‘my-friends’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_my_friends’, ‘position’ => 10, ‘item_css_id’ => ‘friends-my-friends’ ) );
    bp_core_new_subnav_item( array( ‘name’ => __( ‘Requests’, ‘buddypress’ ), ‘slug’ => ‘requests’, ‘parent_url’ => $friends_link, ‘parent_slug’ => $bp->friends->slug, ‘screen_function’ => ‘friends_screen_requests’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );

    if ( $bp->current_component == $bp->friends->slug ) {
    if ( bp_is_my_profile() ) {
    $bp->bp_options_title = __( ‘My Friends’, ‘buddypress’ );
    } else {
    $bp->bp_options_avatar = bp_core_fetch_avatar( array( ‘item_id’ => $bp->displayed_user->id, ‘type’ => ‘thumb’ ) );
    $bp->bp_options_title = $bp->displayed_user->fullname;
    }
    }

    do_action( ‘my_friends_setup_nav’);
    }
    remove_action( ‘bp_setup_nav’, ‘friends_setup_nav’);
    add_action( ‘bp_setup_nav’, ‘my_friends_setup_nav’);

    #63184
    Brajesh Singh
    Participant

    this has been changed

    replace

    bp_get_user_nav()

    with

    bp_get_displayed_user_nav()

    and everything will be working.

    #57297
    Brajesh Singh
    Participant

    ok,so here you go.

    The links are displayed by

    bp_get_displayed_user_nav()

    You can modify it using the following code inside your functions.php

    global $bp;
    if(!bp_is_home())
    $bp->bp_nav[110]=array ( 'name' => 'test','link' => 'test/', 'css_id' =>'test','show_for_displayed_user' => 1 ,'position' => 110 );

    replace test with your link/component name

    Then create some function to handle the link,as shown in the example component.

    Again remember,when you are viewing other’s profile ,the function

    bp_get_loggedin_user_nav()

    and

    bp_get_displayed_user_nav()

    Uses same global variable

    $bp->bp_nav

    to render the navigation,so The link will appear in the userbar for logged in user and in the options bar for the displayed profile.

    Have a look at the code of the two above mentioned methods to look for a workaround.

    #57296
    tiptap
    Participant

    AHH ok.

    It looks like the core function I need to modify is bp_get_displayed_user_nav(); Which is called in the options bar.

    Is it possible to modify that function without going into the core component? ie could i just re-write it and place it in bp-custom.php?

    Thanks for the help so far

Viewing 21 results - 76 through 96 (of 96 total)
Skip to toolbar