 lib/tablelib.php | 6 +++---
 user/index.php   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/tablelib.php b/lib/tablelib.php
index d2ec1e3..7951783 100644
--- a/lib/tablelib.php
+++ b/lib/tablelib.php
@@ -448,7 +448,7 @@ class flexible_table {
 
         if (($sortcol = optional_param($this->request[TABLE_VAR_SORT], '', PARAM_ALPHANUMEXT)) &&
                 $this->is_sortable($sortcol) && empty($this->sess->collapse[$sortcol]) &&
-                (isset($this->columns[$sortcol]) || in_array($sortcol, array('firstname', 'lastname')) && isset($this->columns['fullname']))) {
+                (isset($this->columns[$sortcol]) || in_array($sortcol, array('firstname', 'lastname', 'lastnamephonetic', 'firstnamephonetic', 'middlename', 'alternatename')) && isset($this->columns['fullname']))) {
 
             if (array_key_exists($sortcol, $this->sess->sortby)) {
                 // This key already exists somewhere. Change its sortorder and bring it to the top.
@@ -571,7 +571,7 @@ class flexible_table {
             if (isset($this->columns[$column])) {
                 continue; // This column is OK.
             }
-            if (in_array($column, array('firstname', 'lastname')) &&
+            if (in_array($column, array('firstname', 'lastname', 'lastnamephonetic', 'firstnamephonetic', 'middlename', 'alternatename')) &&
                     isset($this->columns['fullname'])) {
                 continue; // This column is OK.
             }
@@ -1186,7 +1186,7 @@ class flexible_table {
                 if ($nameformat == 'language') {
                     $nameformat = get_string('fullnamedisplay');
                 }
-                $requirednames = order_in_string(array('firstname', 'lastname'), $nameformat);
+                $requirednames = order_in_string(array('firstname', 'lastname', 'lastnamephonetic', 'firstnamephonetic', 'middlename', 'alternatename'), $nameformat);
 
                 if (!empty($requirednames)) {
                     if ($this->is_sortable($column)) {
diff --git a/user/index.php b/user/index.php
index e0737b4..55d21ad 100644
--- a/user/index.php
+++ b/user/index.php
@@ -406,7 +406,7 @@ $joins = array("FROM {user} u");
 $wheres = array();
 
 $extrasql = get_extra_user_fields_sql($context, 'u', '', array(
-        'id', 'username', 'firstname', 'lastname', 'email', 'city', 'country',
+        'id', 'username', 'firstname', 'lastname', 'lastnamephonetic', 'firstnamephonetic', 'middlename', 'alternatename', 'email', 'city', 'country',
         'picture', 'lang', 'timezone', 'maildisplay', 'imagealt', 'lastaccess'));
 
 $mainuserfields = user_picture::fields('u', array('username', 'email', 'city', 'country', 'lang', 'timezone', 'maildisplay'));
