Hammer Time
asked 7 years ago

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’);

1 Answers
answered 7 years ago

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

Hammer Time
replied 7 years ago

That’s awesome! Thanks so much

Powered by DW Question & Answer Pro