Hide/Disable private messaging unless users are friends
-
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.
-
I am also interested in this type of private messaging.
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.
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
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' ) ) : ?>
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?
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
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.
Thanks, r-a-y! Am giving it a try now…
Worked like a charm!! Many thanks.
Cool! Glad it worked for you, Jfcarter.
Make sure to green light the thread!
thanks….
Hiding private messaging is another feature of the BuddyPress Privacy Component.
- The topic ‘Hide/Disable private messaging unless users are friends’ is closed to new replies.