if you have free version of this plugin (users can send msg ONLY to one user), here is the workaround:
2 functions that change user displayed on the list from the author of the first message to user receiving the message, so you will always see with who you are talking:
function fep_cus_fep_participants() {
$meta = get_post_meta(get_the_ID()); // get meta of the msg
$remove = array(get_current_user_id()); // get current user (you)
$meta['_participants'] = array_values(array_diff($meta['_participants'],$remove)); // remove current user from participants, so only receiver will be in array, then reset keys
$user = get_userdata($meta['_participants'][0]); // obtain receiver ID
echo '<span class="fep-message-author">'.$user->display_name.'</span><span class="fep-message-date">'.get_the_time().'</span>';
}
add_action("fep_message_table_column_content_author", 'fep_cus_fep_participants',999);
function fep_cus_fep_participants_avatar() {
$meta = get_post_meta(get_the_ID()); // get meta of the msg
$remove = array(get_current_user_id()); // get current user (you)
$meta['_participants'] = array_values(array_diff($meta['_participants'],$remove)); // remove current user from participants, so only receiver will be in array, then reset keys
$user = get_userdata($meta['_participants'][0]); // obtain receiver ID
echo get_avatar( $user->ID, 55 );
}
add_action("fep_message_table_column_content_avatar", 'fep_cus_fep_participants_avatar',999);
And this one will change the first message to last in conversation in messages list:
function fep_cus_fep_title() {
if( ! fep_is_read( true ) ) {
$span = '<span class="fep-unread-classp"><span class="fep-unread-class">' .__("Unread", "front-end-pm"). '</span></span>';
$class = ' fep-strong';
} else {
$span = '';
$class = '';
}
$p = get_posts(array('post_type'=>'fep_message','post_status'=>'publish','numberposts'=>1,'post_parent'=>get_the_ID()));
?><span class="<?php echo $class; ?>"><a href="<?php
echo fep_query_url('viewmessage', array('id'=> get_the_ID()));
if(!empty($p)) {
$id = $p[0]->ID;
$ad_au = get_user_by('ID',$p[0]->post_author);
if($p[0]->post_author!=get_current_user_id())
$add_author = '<strong>'.$ad_au->display_name.':</strong> '; // this will display author of last message if it's not you (something is not quite right in this one, i haven't tested it much)
} else {
$id = get_the_ID();
}
setup_postdata($id);
?>"><?php the_title(); ?></a></span><?php echo $span; ?><div class="fep-message-excerpt"><?php echo $add_author.fep_get_the_excerpt(100); ?></div><?php
}
add_action("fep_message_table_column_content_title", 'fep_cus_fep_title',999);
Hope it helps, you should be able to get it working simply by putting it in your functions.php
-
This reply was modified 7 years, 11 months ago by
czokalapik. Reason: formatting fix