Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to overwrite a core buddypress function? (3 posts)

Started 1 year, 6 months ago by: Design Cloud

  • Profile picture of Design Cloud Design Cloud said 1 year, 6 months ago:

    First question is
    1) Should this be done by building a plugin or using bp-custom.php?

    My main concern is that im trying to overwrite a function in bp-core.php using a plugin file.

    The function is:

    function bp_core_get_username( $user_id, $user_nicename = false, $user_login = false )

    For some reason the arguments passed in this function are not being picked up in the custom function which I called:

    function bp_core_get_username_custom( $user_id, $user_nicename = false, $user_login = false )

    I used the following add action:

    add_action( 'bp_core_get_username', 'bp_core_get_username_custom', 1,3 );

    Am I doing something obviously wrong or does anyone think there is a deeper problem with my code?

  • Profile picture of rich! @ etiviti rich! @ etiviti said 1 year, 6 months ago:

    there is no action to trigger on (though that wouldn’t allow you to overwrite a function – i don’t believe any “pluggable” functions exists in bp. action is just a hook point)

    there is a filter on the return of that function though bp_core_get_username but passes the determined username

  • Profile picture of Paul Gibbs Paul Gibbs said 1 year, 6 months ago:

    Yeah, there are not any ‘plugable’ functions in BP.