• Resolved Carsten Lund

    (@carsten-lund)


    Hi, I am looking for a way of adding Profile Search in BuddyPress Profile menu next to Profile, Notifications, Messages, Gallery and Settings, and not as an WP menu tab.

    I have added the search form to the Directory, and has expected it to appear.
    How do I achieve this?

    Regards
    Carsten

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Carsten,

    You can create a new page and add it to the BuddyPress menu, then add a search form shortcode to your new page.

    If you add a search form to a directory within the Add to Directory box, it should appear, no further action is required. If that doesn’t happen, try switching to one of the default themes to see if it’s a theme issue.

    Thread Starter Carsten Lund

    (@carsten-lund)

    Hi Andrea, thanks for the reply. I guess there is no easy way within the BP plugin settings to add a new page into BP; I searched the net and found this, is this the way you would recommend, using the bp_core_new_nav_item function as described?

    “Adding New Profile Nav Items To add completely new items to the profile navigation, we will use the bp_core_new_nav_item function. The function has multiple parameters, which are described here.
    Let’s use this code to add a new profile menu item that we will use to display a users posts:…”

    Regards

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Carsten,

    Yes, that’s the function I had in mind. You can use bp_core_new_subnav_item() instead, if you wish to add the new page under one of the existing top level items.

    Thread Starter Carsten Lund

    (@carsten-lund)

    Thank You for your always clear and exact answers

    Thread Starter Carsten Lund

    (@carsten-lund)

    I have not added this function yet, which would probably solve the following issue I see with the BP search integration with the BP menu.

    When a search is done, the BP menu disappears and the only way back to the BP menu, as I see it, is to enter your own profile again?

    Plugin Author Andrea Tarantini

    (@dontdream)

    It’s hard to tell without knowing your custom code but, as far as I know, the BP menu should always be visible. Probably if it doesn’t show up in a given page, that’s because that page contains programming errors.

    Thread Starter Carsten Lund

    (@carsten-lund)

    Hi Andrea, I am trying to ad the bp_core_new_nav_item function to the bp-core/bp-core-buddybar.php navigation array, but I am not sure how this snippet for adding BP Search should look like, would you be so kind showing which snippet I should use?

    Regards
    Carsten

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Carsten,

    You can find the details here:

    https://codex.buddypress.org/developer/function-examples/core/bp_core_new_nav_item/

    Unfortunately I don’t have the time to test it, but the trick is to write a screen function that simply redirects to the page containing the shortcode of your search form, e.g.:

    function my_add_nav ()
    {
        bp_core_new_nav_item( 
            array( 
                ...
                'screen_function' => 'my_screen_function',
                ...
            ));
    }
    
    function my_screen_function()
    {
        wp_redirect( get_page_link (1234) );
        exit;
    }

    Replace 1234 with the actual page ID of your page.

    Thread Starter Carsten Lund

    (@carsten-lund)

    Hi there, Happy Holidays, and thanks for your help.

    As I see it, your answer is two different approaches of making a new item visible in the BuddyPress menu.

    1. The site you are linking to, https://codex.buddypress.org/developer/function-examples/core/bp_core_new_nav_item/
    explains how to ad a new nav item in the BuddyPress menu, but this is, to my knowledge, not possible, as the BP search is not a part of the BuddyPress components?

    2. The description and the code, you are referring to, is how to make a WP page (with the BP search short code) visible in the BuddyPress menu.

    Is this correct?

    Regards
    Carsten

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hello Carsten,

    Thank you, and Happy Holidays to you too!

    Actually the two things are strictly related:

    1. The function bp_core_new_nav_item adds a menu item (any item, not necessarily a BP component), but instead of adding a page link it adds a function (the screen function) that has to do the redirect;

    2. That is a code sample to demonstrate what’s explained above. I didn’t test the code, but as I understand it that should be the way to go.

    Thread Starter Carsten Lund

    (@carsten-lund)

    Hi Andrea,

    I have read the bp_core_new_nav_item() page and I also came across this
    https://rtmedia.io/docs/developers/create-new-buddypress-profile-tab/

    I understand some of the process, but not all.
    I guess that many users want to see this integration of the search module in BuddyPress, so I would really hope to see a step by step guide on this subject, maybe from another member in this forum who has succeeded in adding search to the BuddyPress menu?

    Happy New Year

    Regards
    Carsten

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Carsten,

    Probably I didn’t understand your question – sorry!

    If you wish to add a new BuddyPress Profile Tab, you can use the code you found. Then in the tab content you can display a BP Profile Search form as follows:

    function yourtab_content() { 
        echo do_shortcode ('[bps_display form=234]');
    }

    Replace 234 with the ID of your search form.

    PS: thank you for your review!

    Plugin Author Andrea Tarantini

    (@dontdream)

    duplicate reply removed

    Thread Starter Carsten Lund

    (@carsten-lund)

    Hi Andrea, I am still working on adding profile search as a BP tab.

    >Then in the tab content you can display a BP Profile Search form as follows:<

    I have been looking for a tab content php file, to ad the code, but I can’t find which file you are referring to?

    Is the phrase “yourtab” reffering specific to the name of the page, in this case Search?

    Regards
    Carsten

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Carsten,

    Sorry for the late reply!

    I suggested you follow the tutorial you found in:

    https://rtmedia.io/docs/developers/create-new-buddypress-profile-tab/

    and replace the lines:

    function yourtab_content() { 
        echo 'Content';
    }

    with the lines:

    function yourtab_content() { 
        echo do_shortcode ('[bps_display form=234]');
    }

    Instead of 234 use the ID of your search form.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Adding profile search in BuddyPress Profile menu’ is closed to new replies.