Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

Logout with JS - Wpdiscuz

4 Posts
2 Users
0 Reactions
2,720 Views
(@levanhieu)
New Member
Joined: 6 years ago
Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#4688]

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


This topic was modified 6 years ago by levanhieu

   
Quote
Topic Tags
Elvina
(@elvina)
Support
Joined: 7 years ago
Posts: 1403
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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();
           });
       }
   });


   
ReplyQuote
(@levanhieu)
New Member
Joined: 6 years ago
Posts: 3
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Thank Admin very much. It worked as expected, Wpdiscuz is a great plugin. Admin is also great



   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 7 years ago
Posts: 1403
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

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.



   
ReplyQuote
Share:
Scroll to top