vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=327476

Custom Logout Button
by doc55
22 Aug 2019 18:10

I want to create a custom logout button for my vB 5.3.3.
I'm using the following code from the core/vb/user.php file but it is not working. Can someone help me troubleshoot this code, please?
Thank you


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


doc55 02 Sep 2019 16:39

What do you think about the following method to logout users?
Is it OK or does it cause any issues or security concerns?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Dave 02 Sep 2019 17:01

Use the official vBulletin API. /core/vb/api/user.php has a logout method.

I believe something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


doc55 03 Sep 2019 02:14

Thank you Dave for your helpful reply.
Here is the final and functioning code for others, if they need one:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

One question, with the above code, the user is logged out then redirected to the forum home. My forum is installed in mydomain.com/forum. How can I redirect users after logout to mydomain.com?

--------------- Added 03 Sep 2019 at 16:58 ---------------

Maybe I should ask the question differently.
Is it possible to execute the as a function or in the background, instead of redirecting to it as a URL?

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


delicjous 04 Sep 2019 06:09

Did you try to call the API user logout?

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


doc55 05 Sep 2019 02:45

Quote:

Originally Posted by delicjous (Post 2600532)
Did you try to call the API user logout?

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Thank you for your reply. I did try the API, but I can't make it work.
Here is my code when I use the API:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

With this, I get the following general error from vB:
That action could not be completed. Please try again, and if this occurs again please contact the system administrator and tell them how you got this message.

Maybe you could help me find what I'm doing wrong.
Thanks again.

doc55 26 Sep 2019 01:07

Anyone could help with this script? I really appreciate anu help I can get.

Dave 26 Sep 2019 01:36

I'm pretty sure you must put define('CSRF_PROTECTION', false); on top of the file.

doc55 26 Sep 2019 12:25

Quote:

Originally Posted by Dave (Post 2600775)
I'm pretty sure you must put define('CSRF_PROTECTION', false); on top of the file.

Thank you for your reply.
I tried adding this line on top:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I also tried this line on top:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Both are giving me the same error message and the user is not logged out.

Here is the my final code so far:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Dave 26 Sep 2019 16:37

Works fine if I do

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

instead.

doc55 26 Sep 2019 16:45

Quote:

Originally Posted by Dave (Post 2600789)
Works fine if I do

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

instead.

Thank you Dave. With that change, The script redirects to the index.php as it is expected and I'm not getting any error messages, but the user is not logged out.

Dave 26 Sep 2019 17:06

I used the same script on my vBulletin 5 test forum and it logged me out properly. Maybe try clearing your cookies > login again > try the script.

doc55 26 Sep 2019 18:12

Thank you for your reply.
I just tested it again after clearing the cookies, but still didn't log out the user.
Could this be because I have the option "Remember me" enabled on log-in?

I did var_dump($logoutInfo); and this is what I got:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I'm not sure if this would help.


All times are GMT. The time now is 12:31.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.