BM Private Messaging - A Craft CMS plugin

QUICK AND EASY INSTALLATION, CLEAR AND CONCISE DOCUMENTATION

FREE DOWNLOAD

BM PRIVATE MESSAGING

Grant your site users the power of communication, via private messaging!

ADD PRIVATE MESSAGING TO YOUR SITE IN SECONDS

Installing our plugin is as easy as...

  • 1

    Get

    After purchasing the plugin, download the zip.

  • 2

    Move

    Move the unzipped plugin to the craft/plugin folder

  • 3

    Enable

    Navigate to the plugins section in the Craft admin settings, then click "Install"

1. Send a private message

Add the following form to your template:

<form method="post" action="" accept-charset="UTF-8" id="privateMessagingSendForm">

    <input type="hidden" name="action" value="privateMessaging/message/saveMessage">
    <input type="hidden" name="redirect" value="/message-sent">
    <input type="hidden" name="senderId" value="{{ currentUser.id }}">
    <input type="hidden" name="recipientId" value="{{ recipientId }}">

    <label for="privateMessagingSubject">Subject</label>
    <input type="text" id="privateMessagingSubject" name="subject" value="">

    <label for="privateMessagingMessage">Message</label>
    <textarea id="privateMessagingMessage" name="body" form="privateMessagingSendForm" required></textarea>

    <input type="submit" value="Submit">
</form>

You will need to set the following form values:
  • redirect - This should be set to the template to redirect to, upon successfully sending the private message
  • senderId - This should be the ID of the user sending the message
  • recipientId - This should be the ID of the user due to receive the message

2. View messages

To view the logged in users messages, you will need to add the following to your template:

{% for message in privateMessages %}

{% endfor %}

Within this loop you can access the following private message attributes:
  • message.id - The message ID. [type: integer]
  • message.subject - The subject of the message. [type: string(255)]
  • message.body - The body of the message. [type: text]
  • message.sender - The sender user. [type: user object]
  • message.recipient - The recipient user. [type: user object]
  • message.isRead - Whether the message has been read. [type: boolean]
  • message.dateCreated - The created dateTime of the message. [type: dateTime]

3. View unread message count

To view the unread message count for the currently logged in user, you will need to add the following to your template:

{{ unreadPrivateMessageCount }}

4. View total message count

To view the total message count for the currently logged in user, you will need to add the following to your template:

{{ totalPrivateMessageCount }}

5. View a message

To access an individual message, you will need to pass the id of a message to your template.

This can be achieved by setting up a new route that passes the message id (number) to your template, like so:

Inside the template, we will use this ID (number) to retrieve the message, but, first we check to ensure we have actually been passed an ID:

{% if number is not defined %}
    {% exit 404 %}
{% else %}

If we have an ID, then we pass this to the getPrivateMessage method (which is a twig extension built into the plugin):

{% set message = number|getPrivateMessage %}}

If this method does not return an associated message, it will return false. We may wish to handle that also:

{% if message == false %}
    {% exit 404 %}
{% endif %}

The getPrivateMessage method with return a false value when:
  • Out of range - A message with that ID doesn't exist in the database
  • Deleted - A message with that ID has been deleted from the database
  • Permissions - A message with that ID does not belong to the user trying to access it

6. Delete a message

Add the following form to your template:

<form method="post" action="" accept-charset="UTF-8" id="privateMessagingDeleteForm">
    <input type="hidden" name="action" value="privateMessaging/message/deleteMessage">
    <input type="hidden" name="redirect" value="/messages">
    <input type="hidden" name="id" value="{{ message.id }}">
    <input type="submit" value="Delete">
</form>

You will need to set the following form values:
  • redirect - This should be set to the template to redirect to, upon successfully deleting the private message
  • id - This should be the ID of the message

A user can only delete messages that belong to them.

INTERESTED?

WHAT ARE YOU WAITING FOR?

GRAB YOUR COPY NOW!

FREE DOWNLOAD

FAQ

  • 1. Is this plugin awesome?
    According to global reports at the time of writing, this plugin is the most awesome plugin in the world.
  • 2. How much does the plugin cost?
    £10. It's a deal, it's a steal, it's the sale of the flippin' century.

SUPPORT

  • Need help setting up?...
  • Would you like to see a new feature added?...
  • Found a bug?...

...please feel free to get in touch with us, we'd love to hear from you!

BESPOKE PLUGIN DEVELOPMENT

If you have an idea for a plugin and want to see it come to fruition, contact our team to see how we can help.