Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Custom Message HTML breaks AJAX – why?


  • justarandomuser
    Participant

    @justarandomuser

    Currently I am chaning some BP files to fit them to my Theme.

    The following file I change:
    <my-theme>\buddypress\members\single\messages\message.php

    To check if the current message sender is also the sender of the message just before, I create a class (see below) in the following file:
    <my-theme>\buddypress\members\single\messages\single.php

    class cs_GLOBAL_Msg_Sender_Holder {
      public $last_sender;
    }

    In message.php at the end I write:
    cs_GLOBAL_Msg_Sender_Holder::$last_sender = bp_get_the_thread_message_sender_name();

    At the top of message.php I write:

    <?php if (cc_GLOBAL_Msg_Sender_Holder::$last_sender != bp_get_the_thread_message_sender_name()) : ?>
    // show message with avatar
    <?php else : ?>
    // show message without avatar because it's the same sender like before
    <?php endif; ?>

    But this doesn’t work and breaks AJAX because BP (?) doesn’t like cs_GLOBAL_Msg_Sender_Holder::$last_sender = ...

    What can I do to pass variables like this?

    Or can I get the current AND last sender of a message with global $thread_template; ?

Viewing 1 replies (of 1 total)

  • justarandomuser
    Participant

    @justarandomuser

    OK AJAX is now working. I use now the $GLOBAL variable from WordPress.

    Just the new message, whoch is appended my AJAX, is not correctly dispayed. Will continue to find the problem.

    It looks like the AJAX response (new message) is appended right after <form …> and before the next <div ….>

    <form id="send-reply" action="<?php bp_messages_form_action(); ?>" method="post" class="standard-form">
                <div class="conv-textarea">
                  <?php //do_action( 'bp_before_message_reply_box' ); ?>
                  <textarea name="content" id="message_content" class="auto-height" placeholder=""></textarea>
                  <?php //do_action( 'bp_after_message_reply_box' ); ?>
                  <div class="conv-bottom">                
                    <?php //do_action( 'bp_after_message_reply_box' ); ?>
                    <div class="submit">
                      <input type="submit" name="send" value="<?php esc_attr_e( 'Send Reply', 'buddypress' ); ?>" id="send_reply_button"/>
                    </div>
                    <input type="hidden" id="thread_id" name="thread_id" value="<?php bp_the_thread_id(); ?>" />
                    <input type="hidden" id="messages_order" name="messages_order" value="<?php bp_thread_messages_order(); ?>" />
                    <?php wp_nonce_field( 'messages_send_message', 'send_message_nonce' ); ?>
                  </div>
                </div>
              </form>

    Very strange to put a message there.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar