Reply To: fep_filter_read_receipt example and message recipient


Home Forums Front End PM PRO fep_filter_read_receipt example and message recipient Reply To: fep_filter_read_receipt example and message recipient

#39533
little.chimp
Participant

It’s easy when you know how. Much appreciated.

Final code in my front-end-pm-mod plugin.

add_filter( 'fep_filter_read_receipt_individual', function( $receipt, $time, $participant ){
    if ($time > strtotime('-1 day')) {
    	$time = sprintf( __( '%s', 'front-end-pm' ), date("G:i", $time) );
		// $time = sprintf( __( '%s ago', 'front-end-pm' ), human_time_diff($time) );
	} elseif ($time > strtotime('-6 day')) {
		$time = sprintf( __( '%s', 'front-end-pm' ), date("D G:i", $time) );
	} else { 
		$time = sprintf( __( '%s', 'front-end-pm' ), date("j M Y, G:i", $time) );
	}
	if ( $participant == get_current_user_id()) {
		return '';
	} else {
		return '<div class="fep-msg-read fep-msg-read-pad"><b>Read</b> ' . $time. '</div>';
	}
}, 10, 3);

add_filter( 'fep_filter_read_receipt', function( $output, $receipt ){
	return implode( '', $receipt );
}, 10, 2);

And in related to the other question I asked, how do I get the recipient name (To:). This was as part of a custom template version of veiw-message-content.php.

echo '<div class="fep-msg-author"><b>' . fep_user_name( fep_get_message_field( 'mgs_author' ) ) . '</b></div>';
			$recipients = fep_get_participants( fep_get_the_id( $mgs_id ) );
			foreach ( $recipients as $recipient ) {
				if( fep_get_message_field( 'mgs_author', $mgs_id ) != $recipient )
				echo '<div class="fep-msg-recipient">to ' . fep_user_name( $recipient ) . '</div>';
			}