Hi Admin, I have a question that wants help.
I am using Wpdiscuz and allow users to login from social networks. By default, logout will easily see the logout link. For security, I created a button and processed it using Javascript. However, I cannot get the logout link. That's the problem.
I processed in /wpdiscuz/assets/js/wpdiscuz.js and added:
// ============================== LOGOUT FUNCTION ================ == //
$ (document) .delegate ('. wpdiscuz-log', 'click', function () {
if (isUserLoggedIn){
location.href = "<? php echo wp_loginout (get_permalink (), false)?>";
}
});
Looking forward to the help. Thanks very much
Hi @levanhieu,
This is working partly. The PHP code added by you in js file doesn't work correctly.
To get it resolved, please follow the steps below:
1. Delete all your previous changes.
2. Add the following JS code in the plugin js files.
add_action('wp_ajax_wpdLogout', function () {
$user = wp_get_current_user();
if ($user->ID) {
wp_logout();
}
});
Important: the changes will be lost after wpdiscuz update. You should keep somewhere locally the code.
2. PHP code should be added in the active theme functions.php file:
$(document).delegate('.wpdiscuz-log', 'click', function () {
if (isUserLoggedIn) {
$.ajax({
type: 'POST',
url: wpdiscuzAjaxObj.url,
data: {
action: 'wpdLogout'
},
}).done(function () {
location.reload();
});
}
});
Thank Admin very much. It worked as expected, Wpdiscuz is a great plugin. Admin is also great
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.