Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I actually want my users to have an active user page upon registration. I know that WP doesn't create an author page until the user has created a post but automatically posting something would work it's not what I want to do.

I was going to

add_action('user_register','create_new_user_post');

function create_new_user_post($user_id){
        if (!$user_id>0)
                return;
        // Create post object
        $empty_post = array(
             'post_title' => 'waste of DB space',
             'post_content' => 'an empty post.',
             'post_status' => 'publish',
             'post_author' => $user_id
        );

        // Insert the post into the database
        $bio = wp_insert_post( $empty_post );

        //and if you want to store the post ids in 
        //the user meta then simply use update_user_meta
        update_user_meta($user_id,'_bio_post',$bio);

}

But it seems like a waste to be creating posts in a post type created just to qualify an "author" to have an author page.

Can someone point me in the right direction to get author pages created upon registration without having a post published?

share|improve this question

1 Answer 1

Interesting question, though I have to say it'd be way easier to solve this with a membership plugin - I assume you don't want that.

I have found this plugin which hasn't been updated for over 2 years, however the author.php template hasn't changed much since then. The only way to do this is either querying an author outside of the loop or to capture the 404.php and display the content;

if (!function_exists('show_authors_without_posts')) {

function show_authors_without_posts($template) {
    global $wp_query;
    if( !is_author() && get_query_var('author') && (0 == $wp_query->posts->post) ) {
        // debug
        // echo 'Overwrite default 404 template...';
        return get_author_template();
    }
    return $template;
}

add_filter('404_template', 'show_authors_without_posts');

}

Here's also an answered question with querying an author archive outside of the loop.

share|improve this answer
    
Thanks for your research @rz-requilel I had seen those also but the $curauth; solution does what I'd want but then I'd have to rebuild several things. I don't get 404's but also couldn't get your function to work for me either :( –  BenRacicot Mar 5 '13 at 19:26
    
Did you try the plugin? The code's the same, I have just posted it here to spare you the time to check the code for yourself. –  rz-requilel Mar 5 '13 at 20:33
    
Yes I tried it. It didn't do anything at all for me... Strange. Further research shows me that the author pages are archives which don't become archives until, well... Theres something to archive. I might be barking up the wrong tree here... –  BenRacicot Mar 5 '13 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.