BuddyDev

Search

Buddypress and Yoast

Tagged: ,

  • Participant
    Level: Initiated
    Posts: 4
    alexandra on #3861

    Hi, BuddyDev.

    I have a little problem with the compatibility of BuddyPress and Yoast Seo plugins. I already read this post https://buddydev.com/buddypress/making-wordpress-seo-plugin-compatible-with-buddypress-part-2/
    and tried the solution. It did not help me.
    Let me describe the issue. I don’t use BP for groups etc. I simply use it so that my users have accounts and can write posts on my website.
    I use the following code which redirects to users profiles instead of their archives. I use it in funtions.php

    /* 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.my website name/members/’. $curauth->nickname );
    }
    }

    When I installed Yoast Seo, this code stopped working. So when you click on user name, you get directed to the main page.

    Any ideas how to fix this?
    I would really appreciate any help.

  • Participant
    Level: Initiated
    Posts: 4
    alexandra on #3862

    I use WP 4.5.2 and BP 2.5.2

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #3863

    Hi Alexandra,
    Please remove the code from above post and give it a try

    
    function buddydev_author_redirect_to_profile() {
    
        if ( is_author() && function_exists( 'bp_core_redirect' ) ) {
    
            $author_id = get_queried_object_id();
            bp_core_redirect( bp_core_get_user_domain( $author_id ) );
        }
    }
    add_action( 'template_redirect', 'buddydev_author_redirect_to_profile' );
    
    

    Put it in your functions.php and let me know if it works or not?

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    alexandra on #3879

    Dear Brajesh,

    Do you recommend that I use the code from the article and instead of my code use the new code? I just want to make sure that I do it right.

    Thank you so much

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #3901

    Hi Alexandra,
    You do not need any other code. Just the code from this topic will do it. Please remove any other code if you have already added.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    alexandra on #3912

    Dear Brajesh,

    Thank you so much for your help. I tried the code. It works great when Yoast is off, but it stops working when Yoast is on.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #3915

    Hi Alexandra,
    I just tested it again.

    I am on multisite and I tested with Latest WordPress, BuddyPress and Yoast SEO. The code works great.

    Are you using any specific setting in yoast seo or any 3rd party redirection plugin?

  • Participant
    Level: Initiated
    Posts: 4
    alexandra on #3919

    Dear Brajesh,

    Thank you so much. I’ll take a look at my settings.

You must be logged in to reply to this topic.

This topic is: not resolved