Chris Arnold
asked 5 years ago

Hello, I searched the forums and found several articles on this, but none that seemed to quite answer the question…
1) The display name is shown on the pages, but the username is in the URL.  How can link instead to the username to match my site permalinks structure?

user_login is

Show first and surname instead of username

The second link mentioned I could find my template file in “/plugins/dw-question-answer-pro/templates/styles/default/”.  I updated every reference on every template I could find with “get_the_author_meta( ‘first_name’ )”, but none of them affected the URL at all.
I suspect it has to do with changing the dwqa_get_author_link instead, but have been unable to get a variety of options to return the result I want.
<?php printf( __( ‘<span><a href=”%1$s”>%2$s%3$s</a> %4$s asked %5$s ago</span>’, ‘dwqa’ ), dwqa_get_author_link( $user_id ), get_avatar( $user_id, 48 ), get_the_author_meta( ‘first_name’ ), dwqa_print_user_badge( $user_id ), human_time_diff( get_post_time( ‘U’, true ) ) ) ?>
2) Second question, where in the template files can I update my “profile” page to fix the URL directory manually to say ‘mysite/_mycustomdir_/displayname’.  I see and have tried the option on the backend to select a physical page, but my site uses a permalink that doesn’t have a matching page.
Thanks for the help!

2 Answers
answered 5 years ago

At the moment, the plugin does not support to link to display name instead of username as you mentioned here.

Dominic Staff
replied 5 years ago

About the user profile page, you can find in the plugins/dw-question-answer-pro/templates/styles/default folder.

replied 5 years ago

Thanks for the directory…will try and change the path.

For the non-username, what about nickname instead? Or the first name as mentioned in the other solution (that wasn’t working for me either).


answered 5 years ago

This plugin DOES SUPPORT this option.  Full solution provided in a separate comment thread as there was another bug I had to fix too. Recommend this be provided as the default option on templates.

		<?php // CUSTOM -- Remove null user links & replace registered username with display name
			$user_id = get_post_field( 'post_author', get_the_ID() );
			if ( $user_id == 0 ) {

				printf( __( '<span>%1$s%2$s %3$s answered %4$s ago</span>', 'dwqa' ), get_avatar( $user_id, 48 ), get_the_author(), dwqa_print_user_badge( $user_id ), human_time_diff( get_post_time( 'U', true ) ) );

			} else { ?>

				<?php printf( __( '<span><a href="/user-profile/%1$s">%2$s%3$s</a> %4$s answered %5$s ago</span>', 'dwqa' ), get_the_author_meta('display_name', $user_id), get_avatar( $user_id, 48 ), get_the_author(), dwqa_print_user_badge( $user_id ), human_time_diff( get_post_time( 'U', true ) ) ) ?>

		<?php } ?>
Dominic Staff
replied 5 years ago

Thank you, we will check it.

Powered by DW Question & Answer Pro