From 54b47d19a90dd23ff46ed59c6233a9adef16cde8 Mon Sep 17 00:00:00 2001 From: Giri Date: Sat, 1 Aug 2015 13:32:53 +0530 Subject: [PATCH] 404 error while sending compliments - FIXED --- change_log.txt | 3 +++ includes/bp-compliments-actions.php | 20 ++++++++++++++++++- includes/bp-compliments-forms.php | 3 +++ .../buddypress/members/single/compliments.php | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 80da952..b0b1749 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +v0.0.5 +404 error while sending compliments - FIXED + v0.0.4 Members can see other members compliment page? setting - ADDED diff --git a/includes/bp-compliments-actions.php b/includes/bp-compliments-actions.php index de22d84..6ee5735 100644 --- a/includes/bp-compliments-actions.php +++ b/includes/bp-compliments-actions.php @@ -44,6 +44,7 @@ function handle_compliments_form_data() { } $receiver_name = bp_core_get_user_displayname($receiver_id); + $redirect_url = bp_core_get_user_domain($receiver_id); if ( ! bp_compliments_start_compliment($args)) { @@ -52,7 +53,24 @@ function handle_compliments_form_data() { bp_core_add_message( sprintf( __( 'Your compliment sent to %s.', BP_COMP_TEXTDOMAIN ), $receiver_name ) ); } - $redirect = $redirect_url.'compliments/'; + $bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp')); + $bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes'; + if ($bp_compliment_can_see_others_comp == 'yes') { + $show_for_displayed_user = true; + } else { + $show_for_displayed_user = false; + } + + if (current_user_can( 'manage_options' )) { + $show_for_displayed_user = true; + } + + if ($show_for_displayed_user) { + $redirect = $redirect_url.'compliments/'; + } else { + $redirect = $redirect_url; + } + bp_core_redirect( $redirect ); } } diff --git a/includes/bp-compliments-forms.php b/includes/bp-compliments-forms.php index aefb114..2bcfba0 100644 --- a/includes/bp-compliments-forms.php +++ b/includes/bp-compliments-forms.php @@ -16,6 +16,9 @@ * @param int $receiver_id Compliment receiver ID. */ function bp_compliments_modal_form($pid = 0, $receiver_id = 0) { + if (!$receiver_id && bp_displayed_user_id()) { + $receiver_id = bp_displayed_user_id(); + } ?>
diff --git a/includes/templates/buddypress/members/single/compliments.php b/includes/templates/buddypress/members/single/compliments.php index 32150c2..c25417b 100644 --- a/includes/templates/buddypress/members/single/compliments.php +++ b/includes/templates/buddypress/members/single/compliments.php @@ -25,6 +25,8 @@ $bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes'; if (bp_displayed_user_id() == bp_loggedin_user_id()) { $bp_compliment_can_see_others_comp = 'yes'; + } elseif (current_user_can( 'manage_options' )) { + $bp_compliment_can_see_others_comp = 'yes'; } $page = isset($_GET['cpage']) ? abs((int)$_GET['cpage']) : 1;