Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to modify bp_get_options_nav()?


  • DanielEngelhardt
    Participant

    @danielengelhardt

    Hi,
    i copied the function bp_get_options_nav() from bp-core-template.php to my themes functions.php and named it my_bp_get_options_nav().
    Now i want to modify the profile-link. i created this:

    if ( $subnav_item['css_id'] == 'user-xprofile') {
          $subnav_item['link'] = $subnav_item['link']."/edit/group/1";
        }

    But it doesn’t work. I guess it has to do with the apply_filters-call at the end of the foreach-loop, because it gets echoed:

    echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . esc_attr( $subnav_item['css_id'] . '-' . $list_type . '-li' ) . '" ' . $selected . '><a id="' . esc_attr( $subnav_item['css_id'] ) . '" href="' . esc_url( $subnav_item['link'] ) . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item );

    i also tried `echo apply_filters( ‘my_bp_get_options_nav_’ . $subnav_item[‘css_id’],…’

    Does anybody know what i am missing?
    thanks

Viewing 1 replies (of 1 total)

  • DanielEngelhardt
    Participant

    @danielengelhardt

    In case someone else wants to send users straight to the edit-page when clicking on “profile”-link, i got to manage it this way:
    (THIS HAS TO BE DONE IN wp-content/plugins/bp-custom.php, NOT IN YOUR CHILD THEMES functions.php)

    function my_change_profile_default_subnav() {
      global $bp;
      if (bp_is_my_profile()) {
        bp_core_new_nav_default(array( 'parent_slug' => $bp->profile->slug, 'screen_function' => "xprofile_screen_edit_profile", 'subnav_slug' => $bp->profile->edit->slug));
      }
    }
    add_action( 'bp_setup_nav', 'my_change_profile_default_subnav' );

    What helped me a lot was to temporarily put this snippet into my functions.php:

    function bp_dump() {
        global $bp;
     
        foreach ( $bp as $key => $value ) {
            echo '<pre>';
            echo '<strong>;' . $key . ': </strong><br />';
            print_r( $value );
            echo '</pre>';
        }
        die;
    }
    add_action( 'wp', 'bp_dump' );

    It gives you all the slugs, screen-functions, css-ids and all that good-to-know-stuff.

    Hope this helps 😉

Viewing 1 replies (of 1 total)
  • The topic ‘How to modify bp_get_options_nav()?’ is closed to new replies.
Skip to toolbar