Site logo

[Resolved] Syntax error in Hook from documentation

Home Forums Support [Resolved] Syntax error in Hook from documentation

Home Forums Support Syntax error in Hook from documentation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2486418
    Carsten

    Hi there, when I insert this code snippet from your Using Hooks documentation into a php checker, I get a syntax error about a bracket, both with and without my own code content, but I’mnot able to locate the error.

    Can you help?

    add_action( 'your_hook_name','example_function_name' );  
    function example_function_name() { ?> 
         
    <?php }

    PHP Syntax Check: Parse error: Unmatched ‘}’ in your code on line 28

    add_action( 'bp_after_member_profile_content','example_function_name' );  
    function example_function_name() { ?> 
    
    <span class="block-report">
    	
    <?php  
    
    if ( is_user_logged_in() && function_exists( 'bp_send_private_message_button' ) && bp_is_user() && ! bp_is_my_profile() ) {
    	echo bp_send_private_message_button(bp_displayed_user_id() );
    }
     
    	
    if ( is_user_logged_in() && function_exists( 'bublock_get_button' ) && bp_is_user() && ! bp_is_my_profile() ) {
    echo bublock_get_button(bp_displayed_user_id() ); 	
    }
    	
    		
    if ( function_exists( 'bpmts_report_button' ) && function_exists( 'bpmts_is_me' ) && ! bpmts_is_me( bp_displayed_user_id() ) && bpmts_user_can_report() ) {
     			bpmts_report_button( array(  
          'item_id'    => bp_displayed_user_id(),
          'item_type'  => 'user',
          'context'    => 'bp_user_header',
          'context_id' => bp_displayed_user_id(),
       ) ); 
    }
    		
    ?>
    	
    </span>
    
    <?php }
    #2486497
    Leo
    Staff
    Customer Support

    Hi there,

    I’m not sure why the checker would indicate that – there are no issues from what I can see.

    Just tried adding the code using Code Snippets and received no warnings either.

    #2486967
    Carsten

    Hi there, I detected the issue, the problem was that I had two functions named ‘example_function_name’ in my functions.php, which I can see is not allowed.

    I can’t explain why my php analyser came up with the Unmatched ‘}’ error.

    Thanks!

    #2487372
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.