Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide/Disable private messaging unless users are friends

  • Avatar of Jfcarter
    jfcarter
    Participant

    @jfcarter

    Hello fellow BPers,

    Curious to know if anyone has had success in hiding/disabling private messaging unless users are friends. Got a spammer who likes to come to the site and send everyone a PM asking for money.

    Any help would be appreciated.

    Thanks.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Avatar of intimez
    intimez
    Participant

    @intimez

    I am also interested in this type of private messaging.

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

    @r-a-y

    I had something like this working before in BP 1.1.3.

    You’ll have to modify the /bp-default/members/single/member-header.php file. If you have a child theme, copy this file over and make adjustments.

    Avatar of Jfcarter
    jfcarter
    Participant

    @jfcarter

    @r-a-y,

    Do you have a code snippet that I can start with?

    Bump.

    Anyone made any progress with this?

    check out this function in bp-friends.php

    function friends_check_friendship_status( $user_id, $possible_friend_id ) {

    that will return a string depending on the friend status

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

    @r-a-y

    Try this out in /wp-content/plugins/bp-custom.php:

    function my_bp_is_friend() {
    global $bp;

    if (friends_check_friendship($bp->loggedin_user->id,$bp->displayed_user->id) )
    return true;

    return false;
    }

    Then copy /bp-default/members/single/member-header.php to your child theme.

    Next, edit:

    <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) ) : ?>

    to:

    <?php if ( is_user_logged_in() && !bp_is_my_profile() && my_bp_is_friend() && function_exists( 'bp_send_private_message_link' ) ) : ?>

    Avatar of intimez
    intimez
    Participant

    @intimez

    @r-a-y

    I did what you mentioned but the code in bp-custom.php is now showing up at the top of the page visible to all. Maybe I missed something else?

    edit: ooops, my mistake. It’s working now but I can PM by going direct URL.

    edit2: how to enable so admin can still PM w/o being friends?

    Avatar of shaisimchi
    shaisimchi
    Participant

    @shaisimchi

    There is a function that checks if a user is a site admin (can’t remember the name now but if you can’t find it let me know). you can use it to exclude the admin this allowing him to do send the message.

    Thanks,

    Shai

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

    @r-a-y

    @intimez

    is_site_admin() is the function but will probably be deprecated soon when WP 3.0 comes out.

    Try this out:

    <?php if ( is_user_logged_in() && !bp_is_my_profile() && function_exists( 'bp_send_private_message_link' ) && ( my_bp_is_friend() || is_site_admin() ) ) : ?>

    re: direct url to private message… you’ll have to modify the /bp-themes/bp-default/members/single/messages/compose.php file in your child theme to do a check for the username and if the logged-in user is friends with that username.

    If the username is friends with the logged-in user, show the form to complete the message; if not a friend, don’t show the form.

    Avatar of Jfcarter
    jfcarter
    Participant

    @jfcarter

    Thanks, r-a-y! Am giving it a try now…

    Worked like a charm!! Many thanks.

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

    @r-a-y

    Cool! Glad it worked for you, Jfcarter.

    Make sure to green light the thread! ;)

    Avatar of prathap937
    prathap937
    Participant

    @prathap937

    thanks….

    Avatar of Jeff Sayre
    Jeff Sayre
    Participant

    @jeffsayre

    Hiding private messaging is another feature of the BuddyPress Privacy Component.

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

The topic ‘Hide/Disable private messaging unless users are friends’ is closed to new replies.