I'm trying to set it so that when you view somebody's profile page you see a different template based on their role. So, everybody gets a regular "profile" page but if your also a author you also get a special "editor" page as well.
Normally in Wordpress you get...
www.mysite.com/author/person1
but what I want is...
www.mysite.com/profile/person1
www.mysite.com/profile/person2
www.mysite.com/editor/person2
Below is what I've got so far in my functions.php file but the line that sets variable $curauth doesn't seem to work here. But it does work in my loop.php file???
function change_author_permalinks() {
global $wp_rewrite;
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
var_dump($curauth);
if ( !get_user_role( 'subscriber', $curauth->ID ) ) {
$wp_rewrite->author_base = 'editor';
} else {
$wp_rewrite->author_base = 'profile';
}
$wp_rewrite->flush_rules();
}
add_action('init','change_author_permalinks');