• Resolved Modifiedcontent

    (@modifiedcontent)


    The DW Q&A plugin produces links to author/questioner pages in this format:

    http://mywebsite.com/questions/?user=username

    In my custom theme, multisite, I need them to be in this format:

    http://mywebsite.com/username

    I had added this to functions.php, based on a function in Buddypress:

    function modified_author_link ( $user_id = 0, $user_nicename = false, $user_login = false ) {
    
    if ( empty( $user_id ) ) {
    	return;
    }
    
    $user_info = get_userdata( $user_id );
    $username = $user_info->user_login;
    
    $domain = trailingslashit( network_home_url() . '/' . $username );
    return $domain;
    }
    add_filter( ‘author_link’, ‘modified_author_link’ );

    But it doesn’t do anything. What am I doing wrong? Other suggestions?

    https://wordpress.org/plugins/dw-question-answer/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Modifiedcontent

    (@modifiedcontent)

    I see the mywebsite.com/questions/?user=username comes from User.php. To get the author_link format I want, I have to change this in function dwqa_get_author_link:

    if ( $question_link ) {
    		return add_query_arg( array( 'user' => urlencode( $user->user_login ) ), $question_link );
    	} else {
    		return get_the_author_link( $user_id );
    	}

    …to this:

    if ( $question_link ) {
    		return network_home_url() . $user->user_login;
    	} else {
    		return get_the_author_link( $user_id );
    	}

    Can I do that with a filter?

    Plugin Author DesignWall

    (@designwall)

    Hi modifiedcontent,

    Thank you so much, modifiedcontent. I will add this filter in the next version of DW Q&A.

    Thread Starter Modifiedcontent

    (@modifiedcontent)

    Great. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to change the author link format’ is closed to new replies.