Ejaz Ahmed
asked 10 years ago

I want to remove the default DW QnA login and register textbox and redirect the user to wordpress (/wp-admin) login page. I am also think to give the option to user that the can directly login through their social accounts. I am using wordpress Social login plugin for this.

3 Answers
DominicStaff
answered 10 years ago

Hi Ejaz !
At the moment, we don’t support the social login for Q&A plugin yet, but you can try to find some social login plugins on the WordPress repository, or just check out this article: http://wp.smashingmagazine.com/2012/05/29/login-wordpress-using-social-network/.
After you install a plugin (for ex: wordpress social login plugin), open up the answers.php file in plugins/dw-question-answer/inc/templates/default folder, find the following code (somewhere at the bottom of the file):

<h3 class="dwqa-title">
<?php
printf('%1$s <a href="%2$s" title="%3$s">%3$s</a> %4$s',
__('Please login or','dwqa'),
site_url( 'wp-login.php?action=register' ),
__('Register','dwqa'),
__('to Submit Answer','dwqa')
);
?>
</h3>
<div class="login-box">
<?php wp_login_form( array(
'redirect' => get_post_permalink( $question_id )
) ); ?>
</div>

.. and replace it with your new social login code.
Regards,

Daniel Weller
answered 9 years ago

I used the article you provided http://wp.smashingmagazine.com/2012/05/29/login-wordpress-using-social-network/ to find the wp plugin https://wordpress.org/plugins/wordpress-social-login/. However this is what I used to modify the submit a question section instead of the answer section. 

dw-question-answer/inc/template-functions.php

You can find this section:

<div class="user-email">
<label for="user-email" title="<!--?php _e( 'Enter your email to receive notification regarding your question. Your email is safe with us and will not be published.','dwqa' ) ?>"><!--?php _e( 'Your email *','dwqa' ) ?><!--label>
<input type="email" name="_dwqa_anonymous_email" id="_dwqa_anonymous_email" class="large-text" placeholder="<!--?php
_e( 'Email address ...','dwqa' ) ?>" required>
<span><!--?php printf( __( 'or login to submit question', 'dwqa' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ) ) ) ) ?><!--span>
div>

Edit the span tag to something like this to allow for the option to register or login


<!--?php printf( __( '
*Please Login, ', 'dwqa' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( get_the_ID() ) ) ) ) ?>
<!--?php printf( '%1$s %3$s %4$s', __( '', 'dwqa' ), wp_registration_url(), __( 'Register,', 'dwqa' ), __( 'or provide your email to Submit Question', 'dwqa' ) ); ?>

 

Dominic Staff
replied 9 years ago

Awesome ! Thanks for your solution. 🙂

cagatay
replied 9 years ago

Thank you Daniel, worked like a charm.

Cagatay Belgen
answered 9 years ago

Hello,
Thanks to Daniel, I can now provide social login to users.
The problem is, when a anonymous user clicks on "ask a question" link without social login buttons (first they don’t realize they have to register even I tell them) it redirects to default wp-login page.
How do we force them to use social buttons, or at least how do we hide "ask question" button to anonymous users?
Thanks in advance.

Powered by DW Question & Answer Pro