Created
July 28, 2016 16:56
-
-
Save viruthagiri/2f5eb557d35fe4d60eb9343f6559a944 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function custom_bp_compliments_add_profile_compliment_button() { | |
global $bp; | |
if (!is_user_logged_in()) | |
return; | |
if ($bp->loggedin_user->id == $bp->displayed_user->id) | |
return; | |
$is_friend = friends_check_friendship($bp->loggedin_user->id, $bp->displayed_user->id); | |
if ($is_friend) { | |
bp_compliments_add_compliment_button(); | |
} | |
} | |
remove_action( 'bp_member_header_actions', 'bp_compliments_add_profile_compliment_button' ); | |
add_action( 'bp_member_header_actions', 'custom_bp_compliments_add_profile_compliment_button' ); | |
function custom_bp_compliments_add_members_compliment_button() { | |
$bp_compliment_member_dir_btn_value = esc_attr( get_option('bp_compliment_member_dir_btn')); | |
$bp_compliment_member_dir_btn = $bp_compliment_member_dir_btn_value ? $bp_compliment_member_dir_btn_value : 'no'; | |
if ($bp_compliment_member_dir_btn == 'yes') { | |
$args = array( | |
'receiver_id' => bp_get_member_user_id(), | |
'sender_id' => bp_loggedin_user_id() | |
); | |
$is_friend = friends_check_friendship(bp_loggedin_user_id(), bp_get_member_user_id()); | |
if ($is_friend) { | |
bp_compliments_add_compliment_button($args); | |
} | |
} | |
} | |
remove_action( 'bp_directory_members_actions', 'bp_compliments_add_members_compliment_button' ); | |
add_action( 'bp_directory_members_actions', 'custom_bp_compliments_add_members_compliment_button' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment