Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5123 closed enhancement (fixed)

Add bp_the_thread_message_id() to bp-messages-template.php

Reported by: dtc7240's profile dtc7240 Owned by: boonebgorges's profile boonebgorges
Milestone: 1.9 Priority: normal
Severity: normal Version:
Component: Messages Keywords: has-patch
Cc:

Description

I had a need to get the actual message_id of a message in a thread and found no existing function to easily grab it. Can you please add the following bp_the_thread_message_id() function to the bottom of bp-messages-template.php, just after bp_the_thread_message_content()?

function bp_the_thread_message_id() {
	echo bp_get_the_thread_message_id();
}
	function bp_get_the_thread_message_id() {
		global $thread_template;

		return apply_filters( 'bp_get_the_thread_message_id', $thread_template->message->id );
	}

I modeled it after the existing bp_the_thread_message_content() function:

function bp_the_thread_message_content() {
	echo bp_get_the_thread_message_content();
}
	function bp_get_the_thread_message_content() {
		global $thread_template;

		return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
	}

Many thanks,
Scott Seitz

Change History (4)

#1 @boonebgorges
11 years ago

  • Milestone changed from Awaiting Review to 1.9

Looks good to me. Thanks for the patch.

#2 @boonebgorges
11 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7329:

Introduces bp_get_the_thread_message_id()

This convenience function makes it easier to access the numeric ID of the
current message in the thread.

Fixes #5123

Props dtc7240

#3 @dtc7240
11 years ago

Thanks Boone. Can we add an isset statement? I found that when submitting a message reply, it was throwing a 'Trying to get property of non-object' notice and I'd hate to gunk up people's debug logs...

function bp_the_thread_message_id() {
	echo bp_get_the_thread_message_id();
}
	function bp_get_the_thread_message_id() {
		global $thread_template;

		if ( isset( $thread_template->message->id ) )
			return apply_filters( 'bp_get_the_thread_message_id', $thread_template->message->id );
	}

Thanks again,
Scott

#4 @boonebgorges
11 years ago

dtc7240 - Check out r7329. I am doing an isset() check there.

Note: See TracTickets for help on using tickets.