Skip to:
Content
Pages
Categories
Search
Top
Bottom

How this code works.?


  • bruce30
    Participant

    @bruce30

    hi.
    i hope you can help me. i want to know how this code works.

    function get_id_of_last_message_current_thread() {
      $thread = new BP_Messages_Thread( bp_get_the_thread_id() );
      end($thread->messages)->id;
    }
    add_action('bp_after_message_thread_content', 'get_id_of_last_message_current_thread');
Viewing 2 replies - 1 through 2 (of 2 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    The above code at the moment is not doing anything.
    I will start by explaining.

    The action “bp_after_message_thread_content” is called on single thread page where all messages of a thread(conversation between two people) are listed. It happens at the bottom of that page.

    In your function, you are populating the variable $thread with current thread and all its messages

    The code

    
    
    end($thread->messages)
    

    Forwards the array pointer to the last message and on that object you are accessing the “id”. So it returns the id of the last message. You should store that in some variable and do some further processing to make it more meaningful.

    Hope that helps.


    bruce30
    Participant

    @bruce30

    thanks for your response @sbrajesh, 🙂
    i want to know if this code will help me to know if the message that iv’ed sent to the recipient was viewed or read by the recipient(s).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How this code works.?’ is closed to new replies.
Skip to toolbar