Skip to:
Content
Pages
Categories
Search
Top
Bottom

Is it possible to override bp-core-templatetags functions such as bp_directory_members_search_form

  • Dear all,

    I would like to customize the HTML that is returned by bp_directory_members_search_form() in bp-core-templatetags.php. I seem to kill the app when I attempt to override the function in my functions.php. I’d be grateful for any advice on where to override this function, or is altering the core code the only current option for customization (I’d rather not complicate my ability to update)?

    Thanks,
    Meg

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    Yeah, those functions can’t be simply overridden (like the functions in wp-includes/pluggable.php).

    Your best bet is to do the following:
    1) Copy the entire function you want to replace yo your functions.php, and change the function name (to something like custom_directory_members_search_form() )
    2) Make sure that the template file that calls the template tag (I think it’s members-loop.php, though I’m not in front of my computer at the moment) exists in your child theme. Replace the reference to the original function in that template file to your newly created function name. Then you can customize to your heart’s content.


    cezar
    Participant

    @cezar

    Hi Boone,
    did this to change the text inside the search box for bp_directory_members_search_form but after doing it it broke the ajax sorting (alphabetical, active, newly registered.)
    any thoughts on that?

    thanks,
    Cezar


    Jason
    Member

    @larceniii

    I’m doing something very similar, and I can see how the Order By dropdown could break easily.
    I doubt after a year of no-replies I can expect much help either…


    Roger Coathup
    Participant

    @rogercoathup

    These forums don’t notify people of follow up comments — so, no surprise that Boone didn’t pick up on a further question several months later.

    You can try the @username approach in your comment to notify them


    jashwant
    Participant

    @jashwant

    I added class="form-control" to input and btn class to submit button.

    Hope this helps.

    function cb_bp_directory_members_search_form() {
      $search_form_html = '<form action="" method="get" id="search-members-form">
        <label><input type="text" class="form-control" name="s" id="members_search" placeholder="'. esc_attr( $search_value ) .'" /></label>
        <input type="submit" id="members_search_submit" class="btn"  name="members_search_submit" value="' . __( 'Search', 'buddypress' ) . '" />
      </form>';
      return $search_form_html;
    }
    add_filter('bp_directory_members_search_form', 'cb_bp_directory_members_search_form');
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is it possible to override bp-core-templatetags functions such as bp_directory_members_search_form’ is closed to new replies.
Skip to toolbar