You are here

public static function ShareaholicPublic::get_user_name in Share Buttons, Related Posts, Content Analytics - Shareaholic 8

Same name and namespace in other branches
  1. 7.3 public.php \ShareaholicPublic::get_user_name()

Get the user's name from an account object If the user has a full name, then that is returned Otherwise it returns the user's username

Return value

String the user name

1 call to ShareaholicPublic::get_user_name()
ShareaholicPublic::insert_content_meta_tags in ./public.php
Inserts the shareaholic content meta tags on the page On all pages, it will insert the standard content meta tags On full post pages, it will insert page specific content meta tags

File

./public.php, line 189

Class

ShareaholicPublic
This class is all about drawing the stuff in publishers' templates that visitors can see.

Code

public static function get_user_name($account) {
  $full_name = isset($account->field_fullname) ? $account->field_fullname : false;
  $full_name = isset($account->field_full_name) ? $account->field_full_name : $full_name;
  if ($full_name && isset($full_name['und']['0']['value'])) {
    $full_name = $full_name['und']['0']['value'];
  }
  else {
    $first_name = isset($account->field_firstname) ? $account->field_firstname : false;
    $first_name = isset($account->field_first_name) ? $account->field_first_name : $first_name;
    $last_name = isset($account->field_lastname) ? $account->field_lastname : false;
    $last_name = isset($account->field_last_name) ? $account->field_last_name : $last_name;
    if (!empty($first_name) && !empty($last_name) && isset($first_name['und']['0']['value']) && isset($last_name['und']['0']['value'])) {
      $full_name = $first_name['und']['0']['value'] . ' ' . $last_name['und']['0']['value'];
    }
  }
  return !empty($full_name) ? $full_name : $account->name;
}