Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to redirect author posts archive to profile or blog?


  • Nahum
    Participant

    @nahummadrid

    I will also ask over in the wp multi forums but since I may also try to redirect to BP profile, I’ll see if anyone can help.

    I make use of the author archive on some sites on a MU network but not all, and I also have Sitewide Tags going on one site…on cases like these, I’d like to not use the author archives at all and have the /author/username redirect to the author’s blog in the case of SWT Tags site.

    Any references/links on how to do this?

    If redirect to the users blog is more involved, how about redirecting to the BP Profile?

Viewing 1 replies (of 1 total)

  • Nahum
    Participant

    @nahummadrid

    For anyone else I thought I’d share how I ended up getting this “working”

    So far it looks like it is working — users blogs must be set as their primary site under their My Site settings.

    `add_action( ‘template_redirect’, ‘authorblog_template_redirect’ );
    function authorblog_template_redirect()
    {
    global $wpdb;
    $id = get_query_var( ‘author’ );

    //two lines from bp_adminbar_blogs_menu() in bp-core-adminbar.php

    $blogs = get_active_blog_for_user( $id );

    if ( is_author() ) {

    // get_usernumposts() is deprecated since 3.0
    $post_count = count_user_posts( $id );
    if ( $post_count >= 0 ) {
    //This line could also be wp_redirect
    wp_redirect( $blogs->siteurl );
    exit;
    }
    }

    }

    `

Viewing 1 replies (of 1 total)
  • The topic ‘How to redirect author posts archive to profile or blog?’ is closed to new replies.
Skip to toolbar