on my site user profiles can be accessed on /user/xxx. Now i created a rewrite rule and all user links are handled on the template page. But how can i access the xxx(user) in the template file? The page should display the profile of xxx. Rewite rules:
add_filter( 'query_vars', 'wpleet_rewrite_add_var' );
function wpleet_rewrite_add_var( $vars )
{
$vars[] = 'user';
return $vars;
}
add_rewrite_tag( '%user%', '([^&]+)' );
add_rewrite_rule(
'^user/([^/]*)/?',
'index.php?user=$matches[1]',
'top'
);
add_action( 'template_redirect', 'wpleet_rewrite_catch' );
function wpleet_rewrite_catch()
{
global $wp_query;
if ( array_key_exists( 'user', $wp_query->query_vars ) ) {
include (TEMPLATEPATH . '/user-profile.php');
exit;
}
}