woodyns
asked 8 years ago

I currently use UserPro plugin for WordPress and when a user wants to answer a question (the section is locked to registered users only), when the user clicks on the question the page will display the question and below it gives the username/password boxes for the user to register or login. What I want is to replace that login section with my UserPro login. how can I do that?

3 Answers
Kevin
answered 8 years ago

Hi,

Please add the code below to wp-content/themes/your-theme-folder/functions.php

add_filter( 'dwqa_get_author_link', 'dwqa_theme_change_user_permalink', 10, 2 );
function dwqa_theme_change_user_permalink($link, $user_id) {
	global $userpro;

	if ( $userpro ) {
		$link = $userpro->permalink($user_id)
	}

	return $link;
}
woodyns
replied 8 years ago

Thanks but now I get Parse error: syntax error, unexpected ‘}’Parse error: syntax error, unexpected ‘}’

it is the bracket before the last one in your code. how to fix?

Kevin
replied 8 years ago

Hi,

Please replace with the code below

add_filter( ‘dwqa_get_author_link’, ‘dwqa_theme_change_user_permalink’, 10, 2 );
function dwqa_theme_change_user_permalink($link, $user_id) {
global $userpro;

if ( $userpro ) {
$link = $userpro->permalink($user_id);
}

return $link;
}

woodyns
replied 8 years ago

Thanks, it worked!

woodyns
answered 8 years ago

Well, I did not get the PHP error but the function does not do what I want. I can protect the Ask questions page, that’s not a problem but what I want is that when I click on a question If I am not logged in, the WordPress registration shows below the question. What I want is to display UserPro login/register page I use instead of WordPress. Currently, it still displays the WordPress page. Pls see this link for what I mean

woodyns
replied 8 years ago

Hi

any feedback on this?

woodyns
replied 8 years ago

Hi,

Appreciate if you could give me a solution please?

Kevin
answered 8 years ago

Hi,
You can copy the template answers.php and question-submit-form.php at wp-content/plugins/dw-question-answer-pro/templates/ to wp-content/themes/your-theme-folder/dwqa-templates/ then replace the code following the link below
https://gist.github.com/oryc9x/b31620c9ccfff4b7db42889bacb127be

woodyns
replied 8 years ago

Shall I keep the previous code you gave me or remove it?

Kevin
replied 8 years ago

It’s up to you. It doesn’t make any changes.

woodyns
replied 8 years ago

Thanks, the matter has been resolved and it now works as expected.

Kevin
replied 8 years ago

You’re welcome. Let me know if there is anything else I can help you with 🙂

Powered by DW Question & Answer Pro