Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Remove 'Public Message' button in child theme

  • Profile photo of mort3n
    mort3n
    Participant

    @mort3n

    Hi,

    I have a child theme based on the bp-default theme. In this theme I wish to remove the Public Message button shown next to the avatar when viewing another user’s profile.

    In bp-default/functions php the button is added by
    `add_action( ‘bp_member_header_actions’, ‘bp_send_public_message_button’, 20 );`

    In child-theme/functions php I tried to remove the button by
    `remove_action( ‘bp_member_header_actions’, ‘bp_send_public_message_button’, 20 );`

    This did not work.

    I wonder if the functions php in the child-theme is processed before the functions php in the bp-default theme?

    If so, then how do I remove the button through the child-theme (to ensure that the modification is preserved across updates).

    Any ideas are most welcome!

    Cheers
    Mort3n

Viewing 10 replies - 1 through 10 (of 10 total)
  • Profile photo of mort3n
    mort3n
    Participant

    @mort3n

    Resolved.

    Indeed, the child-theme functions php is called before the parent-theme functions php
    https://codex.wordpress.org/Child_Themes#Using_functions.php

    The function `bp_dtheme_setup()` where the button is added in bp-default is made pluggable as I’ve just learned that it should be 😉

    Therefore, the solution is to override the function in child-theme functions php.

    That is, copy the function `bp_dtheme_setup()` from bp-default/functions php to child-theme/functions php and comment out the lines
    `
    if ( bp_is_active( ‘activity’ ) )
    add_action( ‘bp_member_header_actions’, ‘bp_send_public_message_button’, 20 );
    `

    Hope it helps someone!

    Cheers
    Mort3n

    Profile photo of danbpfr
    danbpfr
    Participant

    @chouf1

    hi,

    or you can also add this piece of code to plugins/bp-custom.php

    `function remove_public_message_button() {
    remove_filter( ‘bp_member_header_actions’,’bp_send_public_message_button’, 20);`

    }
    add_action( ‘bp_member_header_actions’, ‘remove_public_message_button’ );

    https://codex.buddypress.org/developer/customizing/bp-custom-php/

    Profile photo of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    use bp-custom for buddypress code. You preserve you edits if you decide to change or update a theme.

    Profile photo of mort3n
    mort3n
    Participant

    @mort3n

    Hi,

    Thanks for chiming in!

    Good point about bp-custom, will use that instead.

    Cheers
    Mort3n

    Profile photo of applegateian
    applegateian
    Participant

    @applegateian

    Hi guys

    I have tried this code in bp-custom.php as follows but it is not working, am I doing something wrong?

    <?php
    
    // Removing public message option
    
    function remove_public_message_button() {
    remove_filter( ‘bp_member_header_actions’,'bp_send_public_message_button', 20);
    
    }
    add_action( 'bp_member_header_actions', 'remove_public_message_button' );
    
    ?>
    
    Profile photo of bp-help
    bp-help
    Participant

    @bphelp

    @applegateian
    Check the single quotes around bp_member_header_actions. They need to be changed to regular single quotes. If you copied and pasted the code above it would not be right. You can try this in between opening and closing php tags:

    
    // Removing public message option
    
    function remove_public_message_button() {
    remove_filter( 'bp_member_header_actions','bp_send_public_message_button', 20);
    
    }
    add_action( 'bp_member_header_actions', 'remove_public_message_button' );
    
    Profile photo of applegateian
    applegateian
    Participant

    @applegateian

    OK thanks – that unfortunately hasn’t worked though :(

    Profile photo of bp-help
    bp-help
    Participant

    @bphelp

    @applegateian
    I tested it and it works as it should so maybe you need to give more info about your setup because something else is interfering with this function. It could be a plugin as well. Also, have you followed the procedures here in regards to theme compatibility:
    https://codex.buddypress.org/developer/theme-development/a-quick-look-at-1-7-theme-compatibility/

    Profile photo of cdb3212
    cdb3212
    Participant

    @cdb3212

    I tried doing all of that and none of it worked.

    A super simple solution to removing the button is to use CSS:

    #post-mention {display:none;}

    Of course, use in a child theme.

    Profile photo of Hugo
    Hugo
    Moderator

    @hnla

    This is an old thread!

    Using CSS to remove objects in this sense is an incorrect, and unsafe use of CSS.

    The filter does work as described in the original solution run from either bp-custom or functions files or disable messaging for a complete solution.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] Remove 'Public Message' button in child theme’ is closed to new replies.
Skip to toolbar