Skip to:
Content
Pages
Categories
Search
Top
Bottom
Codex HomeDeveloper ResourcesLoops Reference → Private Messages Loop

Private Messages Loop

The private messages loop can be used to output a user’s private messages, both from their inbox and sentbox.

Standard Loop

<?php if ( bp_has_message_threads() ) : ?>

  <div class="pagination-count">
    <?php bp_messages_pagination_count() ?>
  </div>

  <div class="pagination-links">
    <?php bp_messages_pagination() ?>
  </div>

  <ul id="message-threads">
  <?php while ( bp_message_threads() ) : bp_message_thread(); ?>

    <li>
      <!-- Example template tags you can use -->
      <?php bp_message_thread_id() ?>
      <?php bp_message_thread_has_unread() ?>
      <?php bp_message_thread_unread_count() ?>
      <?php bp_message_thread_avatar() ?>
      <?php bp_message_thread_from() ?>
      <?php bp_message_thread_last_post_date() ?>
      <?php bp_message_thread_view_link() ?>
      <?php bp_message_thread_subject() ?>
      <?php bp_message_thread_excerpt() ?>
      <?php bp_message_thread_delete_link() ?>
    </li>
  <?php endwhile; ?>
  </ul>

<?php else: ?>

  <div id="message" class="info">
    <p>There are no messages to display.</p>
  </div>

<?php endif;?>

Accepted Parameters

The bp_has_message_threads() function will accept a number of parameters that will manipulate the data being returned.

Advanced Usage

Fetch inbox messages for the user of ID 12. Get a maximum of 5 messages.

<?php if ( bp_has_message_threads( 'user_id=12&box=inbox&amp;max=5&amp;amp;per_page=5' ) ) : ?>
Skip to toolbar