Available with picu 1.7.0.

Using the following snippet will send an email to your client when they approve a collection, to send them a thank you email.

/**
 * Send a thank-you email to the client after approving the collection
 */
function my_picu_after_approval( $collection_id, $ident ) {

    $picu_mail = new Picu_Emails( $collection_id );
    $args = [];

    // 1. Get client email address
    if ( $ident ) {
        $recipients = get_post_meta( $collection_id, '_picu_collection_hashes', true );
        if ( ! empty( $recipients[$ident] ) ) {
            $args['to_address'] = $recipients[$ident]['email'];
        }
        else {
            return;
        }
    }
    else {
        $args['to_address'] = get_post_meta( $collection_id, '_picu_collection_email_address', true );
    }

    // 2. Prepare other email args
    $args['subject'] = 'Thanks for your approval!';
    $args['mail_parts'] = [
        [
            'type' => 'text',
            'text' => $picu_mail->text_to_html( __( "Thanks for approving the collection!\n\nWe will now be working on your images.\n\nTalk to you soon!", 'my-picu' ) )
        ]
    ];

    // 3. Send email
    $picu_mail->setArgs( $args );
    $picu_mail->send();
}

add_action( 'picu_after_approval', 'my_picu_after_approval', 10, 2 );

Notes:

  • Replace the subject with your own.
  • Replace the email body text with your own. picu emails are comprised of various mail parts. In this example we only use one part with type text.
  • In this example we used plain text, which will converted to HTML using our text_to_html() function. You may also write HTML directly and not use the function.

We’ll have more documentation on which $args are available when sending an email with our Picu_Emails() class soon.

Still having issues?

In your WordPress Admin go to picu > Settings > Debug Info and send the contents of this page and your questions to support@picu.io.