Documentation > How To Guides > Customize Email Content

Customize Email Content

picu sends out a couple of different emails, triggered by various actions either by you, the photographer, or by your clients. All of these emails can be customized. In this guide we’ll explore how to do it.

Email Contexts

The following contexts (kinds of emails) are available and can be used to adjust the content or other aspects of the respective emails:

  • client_collection_new – Email sent to the client, informing them that a new collection is available.
  • client_delivery_new – Email sent to the client, informing them that a new delivery collection is available. (Pro only)
  • photographer_collection_approved – Email sent to the Photographer, informing them that a client has approved their collection.
  • photographer_collection_expired – Email to the photographer, informing them that a collection has expired.
  • client_reminder – Email sent to the client, reminding them that they haven’t yet finished their selection. (Only if the respective setting is turned on.)
  • new_client_confirmation – Email sent to the client after they registered themselves for a collection. (Pro only)
  • photographer_new_order – Email sent to the photographer, informing them, that a new order has come in. (Pro only)
  • client_order_received – Email sent to the client, informing them, that their order was received. (Pro only)

Adjusting Subject and Headers

Adjustments or changes can be made through filters, many of them are listed on the Developers docs page. There you will find filters to adjust the subject of an email or add custom email headers.


Adjusting the Content

The content for the Emails sent to the client for the contexts client_collection_new and client_delivery_new can be set for each collection right in the WordPress Admin. With picu Pro you can also save reusable message templates. These emails can also be formatted using Markdown.

For all other emails we will be using the picu_mail_parts filter to customize the content. It can be used like this:

add_filter( 'picu_mail_parts', 'my_picu_change_email_content', 10, 3 );

Inside your custom function my_picu_change_email_content we can use the aforementioned contexts to only affect the email we want to make adjustments to:

function my_picu_change_email_content( $mail_parts, $mail_context, $collection_id ) {
    if ( $mail_context == 'client_order_received' ) {
        $mail = new Picu_Emails( $collection_id );
        // Change the $mail_parts
    }
}Code language: PHP (php)

Adjusting the mail parts is just a matter of replacing the mail parts:

$mail_parts[0] = [
    'type' => 'text',
    'text' => $mail->text_to_html( "Your custom text goes here." )
];Code language: PHP (php)

You can also add multiple mail parts like so:

$mail_parts = [
    0 => [
        'type' => 'text',
        'text' => $mail->text_to_html( "Your custom text goes here." )
    ],
    1 => [
        'type' => 'button',
        'text' => 'Button Text',
        'url' => 'https://your-url-goes.here'
    ]
];Code language: PHP (php)

Putting it all together:

/*
 * Change the content of the order confirmation email to the client.
 */
function my_picu_change_email_content( $mail_parts, $mail_context, $collection_id ) {
    if ( $mail_context == 'client_order_received' ) {
        $mail = new Picu_Emails( $collection_id );
        // Change the $mail_parts
        $mail_parts = [
            0 => [
                'type' => 'text',
                'text' => $mail->text_to_html( "Your custom text goes here." )
            ],
            1 => [
                'type' => 'button',
                'text' => 'Button Text',
                'url' => 'https://your-url-goes.here'
            ]
        ];
    }

    return $mail_parts;
}

add_filter( 'picu_mail_parts', 'my_picu_change_email_content', 10, 3 );Code language: PHP (php)

Examples

Here are some examples of how to used the aforementioned contexts:

Need help?

If you couldn’t find what you were looking for and need more assistance, please get in touch with us directly and we’re happy to help.