SocialEngine 4: Colour Male & Female Usernames

Little modifications – different colors for Male and Female usernames.
– Male username will be shown as usually – blue colored
– Female usernames will be showed in pink colors

– Functionally for both type – username and displayname.
– In user not entered his/her Gender, usernames will be shown in regular manner – blue.

NOTICE: Before any changes, do backup of User.php file, better than sorry after.
How to?

1. Open file ../application/modules/User/Model/User.php
2. Find code:

public function getTitle()
{
// This will cause various problems
//$viewer = Engine_Api::_()->user()->getViewer();
//if( $viewer->getIdentity() && $viewer->getIdentity() == $this->getIdentity() )
//{
//  $translate = Zend_Registry::get(‘Zend_Translate’);
//  return $translate->translate(‘You’);
//}
if( isset($this->displayname) && ” !== trim($this->displayname) ) {
return $this->displayname;
} else if( isset($this->username) && ” !== trim($this->username) ) {
return $this->username;
} else if( isset($this->email) && ” !== trim($this->email) ) {
$tmp = explode(‘@’, $this->email);
return $tmp[0];
} else {
return “<i>” . Zend_Registry::get(‘Zend_Translate’)->_(“Deleted Member”) . “</i>”;
}
}

3. Replace it with code:

public function getTitle()
{
// This will cause various problems
//$viewer = Engine_Api::_()->user()->getViewer();
//if( $viewer->getIdentity() && $viewer->getIdentity() == $this->getIdentity() )
//{
//  $translate = Zend_Registry::get(‘Zend_Translate’);
//  return $translate->translate(‘You’);
//}
$fields = $this->fields()->getFieldsValuesByAlias();
$gender = $fields['gender'];

if( isset($this->displayname) && ” !== trim($this->displayname) ) {
if(isset($gender) && $gender == ‘3’)        {
return ‘<font color=”#FF0198″>’ .$this->displayname. ‘</font>';
} else {
return $this->displayname ;
}
} else if( isset($this->username) && ” !== trim($this->username) ) {
return $this->username;
} else if( isset($this->email) && ” !== trim($this->email) ) {
$tmp = explode(‘@’, $this->email);
return $tmp[0];
} else {
return “<i>” . Zend_Registry::get(‘Zend_Translate’)->_(“Deleted Member”) . “</i>”;
}
}

That’s it, you’re done :)

Tags: , , , , , , , , , , , , , , , , , | Posted under SocialEngine | RSS 2.0

Author Spotlight

Andrew Cross

Andrew Cross

Hi, I'm Andrew. A am a 26, ICT Administrator which offers support to company's around the South Wales Area. I have created a few social sites for myself and other company's. So far 2 out of 3 have been successful using the powerful SocialEngine Script. I continue to try and help the community of SocialEngine by giving Support and Technical Help where possible.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ 2 = 8

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>