So, I’ve created custom AUTHOR url like
domain.tld/user-nicename, and i have now links like domain.tld/john-doe.
My functions.php is
// AUTHOR
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})/?$"] = 'index.php? author_name=$matches[1]';
}
return $author_rewrite;
}
if( !is_admin() ) {
add_action('init', 'author_rewrite_so_22115103');
}
function author_rewrite_so_22115103() {
global $wp_rewrite;
if( 'author' == $wp_rewrite->author_base ) $wp_rewrite->author_base = null;
}
I am creating users programatically with wp_inser_user, where i set all needed info.
But when I approach domaon.tld/new-user, i’ve got 404 NOT FOUND, until I’ve re-save permalinks.
SO the question is, how can I exactly set this re-saving of permalinks programmaticaly after each use