Create this as a plugin and activate it. It deactivates itself after it creates a primary page for Authors and sub-pages for each Author+ or better Role. At the end, it deactivates itself.
Improve it as you wish. It uses
// Hook activation to create new Author Pages
register_activation_hook(__FILE__, function(){
// Create a Parent Page for all Author Pages
if(!($parent = get_page_by_title('Authors'))){
$parent = wp_insert_post(array(
'post_type' => 'page',
'post_title' => 'Authors',
'post_content' => 'Authors are children of this page.',
'post_status' => 'draft', // Or publish
));
}
if(!$parent){
// Bad... ERROR!
return;
}
// Get user IDs, get_users() returns too much data
global $wpdb;
$IDs = $wpdb->get_col("SELECT `ID` FROM {$wpdb->users} ORDER BY `user_registered` DESC;");
// Loop IDs and create subpages for Authors+ (not Subscribers)
foreach($IDs as $ID){
// Get user
$user = new WP_User($ID);
// Only create pages for Authors!
if(!$user->has_cap('edit_posts')) continue;
// Create page for Author
$title = "About Author: {$user->display_name}";
if(!($child = get_page_by_title($title))){
$child = wp_insert_post(array(
'post_type' => 'page',
'post_title' => $title,
'post_name' => $user->display_name,
'post_content' => 'Write stuff about the Author.',
'post_status' => 'draft', // Or publish
'post_parent' => $parent,
));
// Setup according Metas (for further tracking)
update_post_meta($child, 'about_author', $user->user_login);
update_post_meta($child, 'about_author_ID', $user->ID);
}
}
// Done! WILL RUN JUST ONCE, deactivates itself afterwards.
deactivate_plugins(__FILE__, true);
die;
});
It’s kind of a hacky approach but will do what you need. It uses a PHP 5.3 Closure. Consider reverting to PHP 5.2 compatibility an assignment 🙂
Regards.