We modified the submit-question.php template to redirect to login but wondering if there is a way to update the ask question button to ‘Login to ask question’ by overriding the dwqa_get_ask_question_link function. We noticed your site does this already but we would like to modify the /inc/template-functions.php file but don’t want to lose our changes when doing an update
if (is_user_logged_in())
{
$label = $label ? $label : __(‘Ask a question’,’dwqa’);
} else {
$label = $label ? $label : __(‘Login to ask a question’,’dwqa’);
}
Hi Hammer,
Thanks for writing to us. We checked and made a little change on your code to make it work correctly, you can see that change here:
if( dwqa_current_user_can('post_question') ) {
$label = $label ? $label : __('Ask a question','dwqa');
} elseif( ! is_user_logged_in() ) {
$label = $label ? $label : __('Login to ask a question','dwqa');
$submit_question_link = wp_login_url( $submit_question_link );
} else {
return false;
}
We will update this code in the upcoming version, so you don’t have to worry about update. As you can see on the code snippet, the label is still “Ask a Question” if anonymous can post a question without login. If they can’t, login link will be provided. We also add a filter
$label = apply_filters( 'dwqa_ask_question_link_label', $label );
Through this filter, you can change your button text without worry whenever you update plugin. Hope this help
Regards
That’s awesome! Thanks so much
Please login or Register to submit your answer