MyBB Community Forums

Full Version: MyBB Integrator - How to use logout function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've tried and tried to figure out how to use the MyBB integrator for logout.. the only code example it gives is"
if ($MyBBI->logout())
{
    echo 'You were successfully logged out';
} 

But i cannot figure out how to use that. Does it actually log out?
Basically I want to logout on my site and it keep me there, whereas at the moment it redirects to the forum index after logging out.
managed to solve this. for anybody else that's looking here's how i did it.

-- first I added a form. the key here for me was to add the logout key as a hidden field so it could be accessed.


<?php
   echo '<form class="logout" method="post" action="">
           <input type="hidden" name="logoutkey" value="'.$MyBBI->mybb->user['logoutkey'].'">
           <input type="submit" name="submit" value="Logout" />
       </form>';
?>


-- after that it was just a case of calling the function which referenced the logout key through the GET with a redirect once it had completed the call.


<?php 
       function logout() {
           global $MyBBI;
           echo $_GET['logoutkey'];
           $MyBBI->logout();
       }
       if(isset($_POST['submit']))
       {
          logout();
          header('location:login');
       } 
?>


-- couldn't tell you if this is the perfect way to do it but it works perfectly for me!