Home › Forums › Front End PM PRO › User's own avatar class
- This topic has 3 replies, 2 voices, and was last updated 8 years, 1 month ago by Dominique Baril.
- AuthorPosts
- November 4, 2017 at 3:59 am #7709Dominique BarilParticipant
Hi Shamim,
Against all odds, I modified class-fep-message.php in order to give a new .fep-avatar-own class to current user’s avatar. I don’t know if it’s something you would like to add into a future release, however, here’s the code.
It’s now possible to stylize differently a user’s own avatar or even make It disappear.Have a good day!
case 'avatar' : $participants = fep_get_participants( get_the_ID() ); $current_user = get_current_user_id(); $count = 1; ?> <div class="fep-avatar-p <?php echo ( count( $participants ) > 2 ) ? 'fep-avatar-p-120' : 'fep-avatar-p-90' ?>"><?php foreach( $participants as $p ){ $participant_id = fep_get_userdata( $p, 'ID', 'ID' ); if( $count > 2 ){ echo '<div class="fep-avatar-more-60" title="' . __('More users', 'front-end-pm') . '"></div>'; break; } ?><div class="fep-avatar-<?php echo $count; ?> <?php if ( $participant_id === $current_user) { echo "fep-avatar-own";} ?>"><?php echo get_avatar( $p, 60, '', '', array( 'extra_attr'=> 'title="'. fep_get_userdata( $p, 'display_name', 'ID' ) . '"') ); ?></div><?php $count++; } echo '</div>'; break;November 4, 2017 at 4:02 am #7712Dominique BarilParticipantHere’s the css to remove current user’s avatar
.fep-avatar-own {display: none;} .fep-avatar-p {width:55px; max-width:55px;} .fep-avatar-p .fep-avatar-2 {left:0px;}November 4, 2017 at 12:20 pm #7726Shamim HasanKeymasterIt is highly recommended NOT to modify any core plugin code. When you will update this plugin you will loss all your modification.
Same result can be achieved using
add_action( 'fep_message_table_column_content_avatar', 'your_function' );
Also if you want to remove own avatar you can useif (($key = array_search(get_current_user_id(), $participants)) !== false) { unset($participants[$key]); }just after
$participants = fep_get_participants( get_the_ID() );line.I am planing to add a filter to remove own avatar in next release.
November 5, 2017 at 4:12 am #7766Dominique BarilParticipantAll right, so I added this to my function.php and it works fine. Thanks Shamim
function fep_remove_own_avatar() { $participants = fep_get_participants( get_the_ID() ); if (($key = array_search(get_current_user_id(), $participants)) !== false) { unset($participants[$key]); } $current_user = get_current_user_id(); $count = 1; ?> <div class="fep-avatar-p <?php echo ( count( $participants ) > 2 ) ? 'fep-avatar-p-120' : 'fep-avatar-p-90' ?>"><?php foreach( $participants as $p ){ $participant_id = fep_get_userdata( $p, 'ID', 'ID' ); if( $count > 2 ){ echo '<div class="fep-avatar-more-60" title="' . __('More users', 'front-end-pm') . '"></div>'; break; } ?><div class="fep-avatar-<?php echo $count; ?> <?php if ( $participant_id === $current_user) { echo "fep-avatar-own";} ?>"><?php echo get_avatar( $p, 60, '', '', array( 'extra_attr'=> 'title="'. fep_get_userdata( $p, 'display_name', 'ID' ) . '"') ); ?></div><?php $count++; } echo '</div>'; } add_action( 'fep_message_table_column_content_avatar', 'fep_remove_own_avatar' ); - AuthorPosts
You need to purchase ‘Front End PM PRO’ to create topic in this support forum.
If you already purchased ‘Front End PM PRO’ please LOGIN.