From ac2c43a0db7d379153574e31c7268fc0269470a7 Mon Sep 17 00:00:00 2001 From: Craig Freeman Date: Wed, 10 Apr 2013 09:46:47 -0600 Subject: [PATCH 1/3] Changed parameter to retrieve proper data for role-{rolename}.php to work --- utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility.php b/utility.php index 3e90ed5..5a53513 100644 --- a/utility.php +++ b/utility.php @@ -1383,7 +1383,7 @@ function cfct_cat_id_to_slug($id) { * **/ function cfct_username_to_id($username) { - $user = get_user_by('ID', $username); + $user = get_user_by('login', $username); return (isset($user->ID) ? $user->ID : 0); } From c2988ce180ccfaa57c9752cc89d65cc9729ec2c8 Mon Sep 17 00:00:00 2001 From: Craig Freeman Date: Wed, 10 Apr 2013 10:19:26 -0600 Subject: [PATCH 2/3] Changed paramter to use user slug - usernames with a space weren't working with user login --- utility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utility.php b/utility.php index 5a53513..e2b6ac6 100644 --- a/utility.php +++ b/utility.php @@ -1383,7 +1383,7 @@ function cfct_cat_id_to_slug($id) { * **/ function cfct_username_to_id($username) { - $user = get_user_by('login', $username); + $user = get_user_by('slug', $username); return (isset($user->ID) ? $user->ID : 0); } From c96f39ce991acccb1cb4de0a47b3e0a42dfe866b Mon Sep 17 00:00:00 2001 From: Craig Freeman Date: Wed, 10 Apr 2013 10:50:11 -0600 Subject: [PATCH 3/3] Using post object's author (ID) variable if set --- utility.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/utility.php b/utility.php index e2b6ac6..baf9bd2 100644 --- a/utility.php +++ b/utility.php @@ -506,8 +506,19 @@ function cfct_choose_general_template_type($dir, $files) { function cfct_choose_general_template_role($dir, $files) { $files = cfct_role_templates($dir, $files); if (count($files)) { + $userid = get_query_var('author'); $username = get_query_var('author_name'); - $user = new WP_User(cfct_username_to_id($username)); + + if (isset($userid)) { + $user = new WP_User($userid); + } + elseif (isset($username)) { + $user = new WP_User(cfct_username_to_id($username)); + } + else { + return false; + } + if (!empty($user->user_login)) { if (count($user->roles)) { foreach ($user->roles as $role) {