After installing a plugin “Login With AJAX”(version 3.0.4 or less), I faced a issue with wordpress logout. The issue was:
The user is kept logged-in even after the browser is closed !! The user needs to logout explicitly from the site.
In general, browser clears the cookies(Session Cookies) set by WordPress for the logged-in user when the browser is closed, but the way “login-with-ajax” submits the login-form data, it always set the “remember me” value to something(long time in future) which makes the cookie as persistent. So the cookie never expires and user is kept logged-in always evenif browser is closed.
Follow the steps below for a quick fix to the above problem:
- – Read the section “Customizing the Widget” here http://wordpress.org/extend/plugins/login-with-ajax/other_notes/ so that we can change a cor plugin file.
- – Open the file “login-with-ajax.source.js” inside the widget directory and copy the whole code inside it, then paste the code into the file “login-with-ajax.js” and save. We are doing this to have un-minified version of code, for ease of editing. 🙂
- – Search the function “getPostData” and add the below lines after el = $(el);
if(el.is('input:checkbox') && !(el.is(':checked'))) { return; }
- – Code after changing, looks like below:
function getPostData(selector) { var postData = {}; $.each($(selector), function (index, el) { el = $(el); if(el.is('input:checkbox') && !(el.is(':checked'))) { return; } postData[el.attr('name')] = el.attr('value'); }); return postData }
- – Save and check. 🙂 Now, after browser close, it should be logging out the wordpress user
Leave a Reply