Hi there, I’m using this code snippet supplied by you to position Send Private message, Block and Report buttons after member profile content, using this hook
bp_after_member_profile_content
Send Message and Report buttons links are working, but the Block link does not respond when clicked.
There are no syntax errors, but looking at the code for Block and Report show som differences in the if statements, where you would expect them to be alike. Are these statements correct?
Regards
Carstenadd_action( 'bp_after_member_profile_content', 'block_report__function' ); function block_report__function() { ?> <span class="block-report"> <?php if ( is_user_logged_in() && function_exists( 'bp_send_private_message_button' ) && bp_is_user() && ! bp_is_my_profile() ) { $args = array( 'user_id' => bp_displayed_user_id(), 'button_class' => 'my-button-class' ); echo bp_send_private_message_button( $args ); } if ( is_user_logged_in() && function_exists( 'bublock_get_button' ) && bp_is_user() && ! bp_is_my_profile() ) { $args = array( 'user_id' => bp_displayed_user_id(), 'button_class' => 'my-button-class' ); echo bublock_get_button( $args ); } if ( function_exists( 'bpmts_report_button' ) && function_exists( 'bpmts_is_me' ) && ! bpmts_is_me( bp_displayed_user_id() ) && bpmts_user_can_report() ) { $args = array( 'item_id' => bp_displayed_user_id(), 'item_type' => 'user', 'context' => 'bp_user_header', 'context_id' => bp_displayed_user_id(), 'button_class' => 'my-button-class' ); echo bpmts_report_button( $args ); } ?> </span> } <?php
Hi Carsten,
Thank you for reporting the issue.I don’t see any error.
Can you check the browser console and see if there is any js error appearing?Regards
BrajeshHi Brajesh, thanks, this is what the console shows when the link is clicked.
Regards
CarstenRequest URL: https://domain/wp-admin/admin-ajax.php
Request Method: POST
Status Code: 403
Remote Address: 31.xxx.xx.xxx:443
Referrer Policy: strict-origin-when-cross-originjquery.min.js?ver=3.6.1:2 POST https://domain/wp-admin/admin-ajax.php 403
send @ jquery.min.js?ver=3.6.1:2
ajax @ jquery.min.js?ver=3.6.1:2
s.ajax.s.ajax @ jquery-migrate.min.js?ver=3.3.2:2
S.<computed> @ jquery.min.js?ver=3.6.1:2
(anonymous) @ bublock.js?ver=1.0.4:3
dispatch @ jquery.min.js?ver=3.6.1:2
y.handle @ jquery.min.js?ver=3.6.1:2Hi Carsten,
From the screenshot, It seems something is preventing access to admin-ajax.
Do you have any rule/plugins restricting access to WordPress dashboard or wp-admin/admin-ajax.phpThat seems to be causing this.
Please check.
Regards
BrajeshHi Brajesh, I have access to the dashboard, and I guess such a rule or plugin would create issues elsewere as well.
Besides, the Report link from BuddyPress Moderation Tools next to the Block link works well, wouldn’t it be the same logic if something overall prevented access to admin-ajax?
Furthermore, the Block link is working if it’s added to the Profile Header.
Regards
Carsten- This reply was modified 1 year, 9 months ago by calu.
Hi Carsten,
I can not investigate the request form the screenshot but the response code is 403(forbidden).
If other ajax features are working that means the request being sent is not sending the proper details(item type, id, nonce etc).If you want, I can check it on the site and see what is causing it.
Regards
Brajesh
The topic ‘ [Resolved] Block button does not respond.’ is closed to new replies.