Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filtering bp_get_send_message_button()?


  • adamt19
    Participant

    @adamt19

    It looks like bp_get_send_message_button is reserved for private messages only, and returns a filtered result of bp_get_button according to some private-message-specific parameters.

    I’d like to remove the term “Private” from the language, since it is the only kind of messaging I’m going to use, but with two additional requirements:

    1) I don’t want to deal with language files
    2) I want to keep the customization on this element of BP with the other customizations — i.e. in my functions.php

    It seems I cannot redefine bp_get_send_message_button in my functions.php. When I use an if (!function_exists.. my changes are ignored. When I remove the check, the conflict between the functions is fatal.

    How can I override the link_title and link_text without modifying BP core or using language files?

    function bp_get_send_message_button() {
    		// Note: 'bp_get_send_message_button' is a legacy filter. Use
    		// 'bp_get_send_message_button_args' instead. See #4536
    		return apply_filters( 'bp_get_send_message_button',
    			bp_get_button( apply_filters( 'bp_get_send_message_button_args', array(
    				'id'                => 'private_message',
    				'component'         => 'messages',
    				'must_be_logged_in' => true,
    				'block_self'        => true,
    				'wrapper_id'        => 'send-private-message',
    				'link_href'         => bp_get_send_private_message_link(),
    				'link_title'        => __( 'Send a private message to this user.', 'buddypress' ),
    				'link_text'         => __( 'Private Message', 'buddypress' ),
    				'link_class'        => 'send-message',
    			) ) )
    		);
    	}
Viewing 2 replies - 1 through 2 (of 2 total)

  • modemlooper
    Moderator

    @modemlooper

    change whatever you want in the arguments

    function filter_send_message_btn() {
    
    		$args = array(
    			'id'                => 'private_message',
    			'component'         => 'messages',
    			'must_be_logged_in' => true,
    			'block_self'        => true,
    			'wrapper_id'        => 'send-private-message',
    			'link_href'         => bp_get_send_private_message_link(),
    			'link_title'        => __( 'Send a private message to this user.', 'buddypress' ),
    			'link_text'         => __( 'Private Message', 'buddypress' ),
    			'link_class'        => 'send-message',
    		);
    
    		return $args;
    
    }
    add_filter('bp_get_send_message_button_args', 'filter_send_message_btn');

    adamt19
    Participant

    @adamt19

    It’s always simpler than I think, with BuddyPress.

    Thanks! (RESOLVED)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filtering bp_get_send_message_button()?’ is closed to new replies.
Skip to toolbar