WordPress: Write a personal log

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>';
}

2 comments to "WordPress: Write a personal logout"

  1. October 27, 2008 Francis Gaven :

    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!

  2. March 4, 2010 Ivan :

    Congratulations for the tutorial

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL