BuddyDev

Search

[Resolved] Block button does not respond.

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48821

    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
    Carsten

    add_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
  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48822

    Last line edited, due to syntax error <?php }

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #48830

    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
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48832

    Hi Brajesh, thanks, this is what the console shows when the link is clicked.

    Regards
    Carsten

    https://imgur.com/hyrn61j

    Request 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-origin

    jquery.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:2

  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #48833

    Hi 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.php

    That seems to be causing this.

    Please check.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48834

    Hi 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, 8 months ago by calu.
  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #48840

    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

  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48842
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 24636
    Brajesh Singh on #48843
    This reply has been marked as private.
  • Participant
    Level: Yogi
    Posts: 1117
    calu on #48844
    This reply has been marked as private.

The topic ‘ [Resolved] Block button does not respond.’ is closed to new replies.

This topic is: resolved