Skip to:
Content
Pages
Categories
Search
Top
Bottom

Override a BP class function

  • Avatar of simonwillan
    simonwillan
    Participant

    @simonwillan

    BuddyPress version: 2.0.1
    Wordpress version: 3.9.1

    Hi all,

    As part of an ongoing project, the wp_bp_friends table for us is of no use as we have our own system in place. That being said, the function bp_add_friend_button(); is regularly used and rather than changing all occurrences of this function to a custom one, we’d like to just override the function. I have noticed bp_get_add_friend_button(); has an apply_filter at the bottom so I can filter it, however filtering doesn’t help as that function still executes “bp_is_friend()” and “bp_is_friend()” tries to access the wp_bp_friends table (which has a completely different structure now)

    Is there anyway I can override bp_add_friend_button(); and stop it from running any of the BP based content so we can just generate our own without having to replace the function call all over the project?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of simonwillan
    simonwillan
    Participant

    @simonwillan

    In fact, ideally we’d like to override what check_is_friend() does, without hacking the core file.

    is this possible?

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    If you’re not using the Friends component, why not disable it under the BuddyPress components menu?

    http://codex.buddypress.org/getting-started/configure-components/

    Uncheck “Friend Connections” and save.

    If you’re using the wp_bp_friends table in weird ways. Disable the friends component and create your own custom component plugin referencing this table. You should really have created a new table and namespaced it differently to avoid these issues you’re running into.

    You could also try removing the button:
    remove_action( 'bp_member_header_actions', 'bp_add_friend_button', 5 );

    This would need to be called before the page loads.

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

You must be logged in to reply to this topic.