Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to redirect to user profile

Viewing 6 replies - 1 through 6 (of 6 total)

  • alexandra55
    Participant

    @alexandra55

    I tried to use BP Blog Author Profile Link plugin. It did not work for me


    Bowe
    Participant

    @bowromir

    @alexandra55 you can achieve this by adding a little snippet to your bp-custom.php or functions.php.

    add_action( 'template_redirect', 'themename_redirect_author_archive_to_profile' );
    function themename_redirect_author_archive_to_profile() {
      if(is_author()){
        $user_id = get_query_var( 'author' );
        wp_redirect( bp_core_get_user_domain( $user_id ) );
      }
    }

    Hope this helps!


    alexandra55
    Participant

    @alexandra55

    @bowromir thank you so much for your reply. Unfortunately, it did not work for me. It seems that there is a problem with the following function: function themename_redirect_author_archive_to_profile


    alexandra55
    Participant

    @alexandra55

    It seems that this might work

    /* check if custom function file is active */
    if( file_exists( WP_CONTENT_DIR . ‘/meso-custom-functions.php’ ) ) {
    include_once( WP_CONTENT_DIR . ‘/meso-custom-functions.php’ );
    }

    add_action( ‘template_redirect’, ‘authorblog_template_redirect’ );
    function authorblog_template_redirect(){
    if(is_author()){
    if(get_query_var(‘author_name’)) :
    $curauth = get_user_by(‘slug’, get_query_var(‘author_name’));
    else :
    $curauth = get_userdata(get_query_var(‘author’));
    endif;
    wp_redirect(‘http://www.your wesite name/members/’. $curauth->nickname );
    }
    }


    shanebp
    Moderator

    @shanebp

    It helps a lot if you give some info about the ‘problem’.

    In this case, I think he just forgot the exit() call.

    Try changing to:

    wp_redirect( bp_core_get_user_domain( $user_id ) );
    exit();

    alexandra55
    Participant

    @alexandra55

    @shanebp Thank you so much. I’ll try that

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar