-
-
Save charleslouis/5138861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*** beginning of the code to paste in your functions.php ***/ | |
function imath_pm_button_only_if_friends( $button ) { | |
if( is_super_admin() ) | |
return $button; | |
if( 'is_friend' != friends_check_friendship_status( bp_displayed_user_id(), bp_loggedin_user_id() ) ) | |
return false; | |
else | |
return $button; | |
} | |
add_filter( 'bp_get_send_message_button', 'imath_pm_button_only_if_friends', 10, 1 ); | |
function imath_fillfield_only_if_friends() { | |
if( empty( $_GET['r'] ) ) | |
return; | |
if( is_super_admin() ) | |
return; | |
$path = esc_url( $_SERVER['REQUEST_URI'] ); | |
$redirect = bp_core_get_root_domain() . $_SERVER['REDIRECT_URL']; | |
preg_match('/[\?r] *= *["\']?([^"\' ]*)[\& ]/is', $path, $match ); | |
if( !empty( $match[1] ) ) { | |
$user_id = bp_core_get_userid( $match[1] ); | |
if( 'is_friend' != friends_check_friendship_status( $user_id, bp_loggedin_user_id() ) ) | |
bp_core_redirect( $redirect ); | |
} | |
} | |
add_action( 'messages_screen_compose', 'imath_fillfield_only_if_friends' ); | |
/*** end of the code to paste in your functions.php ***/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment