Starting from the post WordPress: step by step how to create their own login , performed the login procedure could be useful to indicate in our Blog Link to disconnect or log out. We will not use again the standard procedures of WordPress, but as we will see log out at a low level. First we must determine whether a user is logged in or not. This is possible simply by querying the variable $user_ID WordPress. For example:
1 2 3 | $user_ID != '' ) { // oppure if( is_user_logged_in() ) { if ($ user_id! ='') {/ / or if (is_user_logged_in ()) { / / A user is "logged in" ... } |
Once we know that a user is "logged" into the system, we can insert a simple link to our logout page. Then create a page, for example, logout.php , and inserting the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | / ** * Performs logout * * @ Author Giovambattista Fazioli * @ @ Email g.fazioli undolog.com * @ Web http://www.undolog.com * / / / Invoke bootstrap WordPress ( 'wp-config.php' ) ; @ Require_once ('wp-config.php'); ( 'wp-includes/pluggable.php' ) ; @ Require_once ('wp-includes/pluggable.php'); / / Wp logout wp_logout (); / / Load any other page "Location: /" ) ; header ("Location: /"); |
And just then "link" our procedures to provide a logout:
1 2 3 | $user_ID != '' ) { if ($ user_id! ='') { ; echo 'Run <a href="logout.php"> logout </ a>'; } |










That's why I love WordPress. Every day you can come and accomplish something in mind (as demonstrated by your tutorial) in just a few steps!
Congratulations for the tutorial