Change the subscribed user email based on a role

ProjectHuddle includes filters to change the email users receive when they are subscribed to a project. Here's an example on how to change it based on role:

<?php
/**
 * Change the collaborate subject for project clients
 */
function wp395_ph_change_collaborate_subject( $subject, $email, $user, $post_id ) {
	// if user is a project client
	if ( user_can( $user, 'project_client' ) ) {
		$subject = 'Your Design Project is in progress.';
	}


	return $subject;
}


add_filter( 'ph_subscribe_user_email_subject', 'wp395_ph_change_collaborate_subject', 10, 4 );


/**
 * Change the collaborate message for project clients
 */
function wp987_ph_change_collaborate_message( $message, $email, $user, $post_id ) {
	// if user is a project client
	if ( user_can( $user, 'project_client' ) ) {
		// project link
		$project_link = get_the_permalink( $post_id );


		// add message
		$message = '<p>Your design project is in progress!</p>';
		$message .= '<p>' . __( 'View the project here:', 'project-huddle' ) . '</p>';
		$message .= '<p><a href="' . esc_url( $project_link ) . '">' . esc_url( $project_link ) . '</a></p>';
	}


	return $message;
}


add_filter( 'ph_subscribe_user_email_subject', 'wp987_ph_change_collaborate_message', 10, 4 );

These two functions change the subject and the message for the email. You can see how you can change it based on other properties too, like a post id or a specific user id too.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.