weretravellers
asked 7 years ago

I would like to change the URL that the username and avatar takes you to so whoever clicks on it get to the users profile instead of the question archive. Is that possible?
My user profiles URL is: http://weretravellers.com/profile/<?php the_author_meta( user_login ); ?>
Thank you in advance

1 Answers
Allen
answered 7 years ago

Yes, it can but you can modify code abit:

first you have to
Open file in (wp-content/plugins/dw-question-answer/inc/User.php) : go to line 179 and change the code to:

return add_query_arg( array( 'user' => urlencode( $user->user_login ), 'post_type' => 'dwqa'), $question_link );

after that, in your functions file, you need to add a redirect function to the file you want 

 add_action( 'template_redirect', 'dwqa_redirect_author_archive_to_profile' );
function dwqa_redirect_author_archive_to_profile() {
 $user_login = isset( $_GET['user'] ) ? $_GET['user'] : null;
if( $_GET['user'] && $_GET['post_type'] == 'dwqa' ){
 
 $user = get_user_by( 'login', $user_login );
 wp_redirect( < that user page >  );
 }
}
Powered by DW Question & Answer Pro