bp_thread_has_messages( array|string $args = '' )

Initialize the messages template loop for a specific thread.


Parameters Parameters

$args

(array|string) (Optional) Array of arguments. All are optional.

  • 'thread_id'
    (int) ID of the thread whose messages you are displaying. Default: if viewing a thread, the thread ID will be parsed from the URL (bp_action_variable( 0 )).
  • 'order'
    (string) 'ASC' or 'DESC'. Default: 'ASC'.
  • 'update_meta_cache'
    (bool) Whether to pre-fetch metadata for queried message items. Default: true.

Default value: ''


Top ↑

Return Return

(bool) True if there are messages to display, otherwise false.


Source Source

File: bp-messages/bp-messages-template.php

function bp_thread_has_messages( $args = '' ) {
	global $thread_template;

	$r = bp_parse_args( $args, array(
		'thread_id'         => false,
		'order'             => 'ASC',
		'update_meta_cache' => true,
	), 'thread_has_messages' );

	if ( empty( $r['thread_id'] ) && bp_is_messages_component() && bp_is_current_action( 'view' ) ) {
		$r['thread_id'] = (int) bp_action_variable( 0 );
	}

	// Set up extra args.
	$extra_args = $r;
	unset( $extra_args['thread_id'], $extra_args['order'] );

	$thread_template = new BP_Messages_Thread_Template( $r['thread_id'], $r['order'], $extra_args );

	return $thread_template->has_messages();
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.