Adding title profile field (like Dr.,Prof.,Er.) before user’s name

To do this please add a profile field named as Title(case sensitive) from wp-admin -> users-> profile fields :

then please add the given code in your wplms-customizer.php file in wplms customizer plugin :

add_filter('bp_core_get_user_displayname','add_title_before_instrutor_name',10,2);
add_filter('bp_displayed_user_fullname','add_title_before_instrutor_name2');
add_filter('bp_get_loggedin_user_fullname','add_title_before_instrutor_name2');
function  add_title_before_instrutor_name($name,$user_id){
  $field = bp_get_profile_field_data(
  array(
  'field' => 'Title', // where 1 is the field_id or it can be the field name
  'user_id' => $user_id
  ));
  return $field.' '.$name;
}
function  add_title_before_instrutor_name2($name){
  $field = bp_get_profile_field_data(
  array(
  'field' => 'Title', // where 1 is the field_id or it can be the field name
  'user_id' => (!empty(bp_displayed_user_id())? bp_displayed_user_id() :get_current_user_id())
  ));
  return $field.' '.$name;
}

 

It will look like this :

722ddeebc9e44e22ad7275eddfe502af

Leave a Reply

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