Do I need to flush rewrite rules when creating new user if using custom author rewrite rules?
I am using custom urls for my author pages like this:
http://site.com/author_name
After I create a new user, that author page appears as not found; however, if I update my permalink structure from admin panel, the author page is found.
So, is it necessary to flush rewrite rules after a new user is created? Is there any other way?
From codex, I read that flushing rewrite rules is a very expensive task. So, I would like to avoid this. Is it possible?
EDIT:
add_filter('author_rewrite_rules', 'no_author_base_rewrite_rules');
function no_author_base_rewrite_rules($author_rewrite) {
global $wpdb;
$author_rewrite = array();
$authors = $wpdb-get_results("SELECT user_nicename AS nicename from $wpdb-users");
foreach($authors as $author) {
$author_rewrite["({$author-nicename})/page/?([0-9]+)/?$"] = 'index.php?author_name=$matches[1]paged=$matches[2]';
$author_rewrite["({$author-nicename})/?$"] = 'index.php?author_name=$matches[1]';
}
return $author_rewrite;
}
add_filter('author_link', 'no_author_base', 1000, 2);
function no_author_base($link, $author_id) {
$link_base = trailingslashit(get_option('home'));
$link = preg_replace("|^{$link_base}author/|", '', $link);
return $link_base . $link;
}
Topic wp-create-user rewrite-rules Wordpress performance
Category Web