Skip to:
Content
Pages
Categories
Search
Top
Bottom

Restricting private messages


  • devbad
    Participant

    @devbad

    I am looking for some help with restricting private messages.

    I have Paid Memberships Pro – BuddyPress Add On Version 1.2.1 and BP Better Messages (Premium) Version 1.9.7.9 with WordPress 5.1
    BuddyPress Version 4.2.0

    I am looking for a way to restrict the private message option for certain type of users. I am trying to have this modification multiple ways, with and without PMPro but none of them working so far.

    With PMPro I supposed to restrict easily, still I can only totally restrict all BuddyPress functions or enable all of them, customization looks like broken.

    I looked into the codes of all the mentioned plugins, tried to restrict access by using below code that I found in another topic:

    add_filter( 'bp_get_send_message_button', function( $array ) {
        if ( pmpro_hasMembershipLevel('Premium') ) {
            return $array;
        } else {
            return '';
        }
    } );

    Maybe I am just trying to make it too complicated and there is an easier way to do it with shortcodes under the Members page that currently contains only [bps_directory] shortcode.

    Any suggestion and help would be welcome.

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

  • Venutius
    Moderator

    @venutius

    Hi there, are you using the Nouveau template at all? If so I reckon a better way to do this would be to remove the private message button from the buttons array using the bp_nouveau_get_members_buttons filter.

    So something like:

    add_filter( 'bp_nouveau_get_members_buttons', 'venutius_check_private_message_button' );
    
    function venutius_check_private_message_button( $buttons ) {
        if ( ! pmpro_hasMembershipLevel('Premium') ) {
            unset( $buttons['private_message'] );
        }
        return $buttons;
    }

    devbad
    Participant

    @devbad

    Sorry, I forgot to mention that yes, I am using the Nouveau template.
    Considering the plugins that I am using with the Nouveau template, where exactly should I insert this code? I mean to which file to get the result and not being overridden by another plugin or template?


    Venutius
    Moderator

    @venutius

    You can put it in the functions.php file of a child theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar