WordPress Tip: Function is_user_logged_in

A PHP function is available in WordPress called is_user_logged_in that is very useful if you want to know if a user is logged in.  Why on earth would you want to know this?  Have you ever thought about adding custom content to your blog that only you can see or only logged in (registered users) can see?

If so this function is for you.  I recently updated my blog’s theme and realized that it has some space that could be used for secondary navigation.  nolinks1 The area in red seemed to me like a great place for additional links.

This is where the function is_user_logged_in can help me out.   In this case the area highlighted in red has its own div tag.  It currently looks like this:

<div id=”nav-space”></div>

Inside the div tag I place the following 2 lines.

<?php if (is_user_logged_in()){ ?>
<?php } ?>

The 2 lines call the function is_user logged_in and evaluate the return value with my if statement. The second statement simply closes or ends the if. Do not worry if you do not understand.  Let me just tell you what it does.

Suffice it to say that anything you put between the 2 lines will be seen by logged in users only. For this example I am going to insert a link.

<div id=”nav-space”>
<?php if (is_user_logged_in()){ ?>
<a href=”http://www.google.com”>Google</a>
<?php } ?>

In the example just above a link to Google will be placed in the red area above that can only be seen by a logged in user.  In this case, me!

Now let’s put it in to practice.    I have added 3 links to the red bar section.  I now have access to facebook, friendfeed, and twitter right in my header section. I like this.  I think I will add some additional links later.

Now remember they will only display if you are logged in.  If you are like me you mainly use the same computers and stay logged in.  As long as you are logged in you will see your links.

Do you hang out on your own blog alot?  Would you like to use your own blog for a mini portal? Do you have free navigation space available?

This is great for me and adds functionality for my purposes but leaves the blog crisp and clean for visitors.  Try this WordPress trick in your theme today.

Linked June 1-3 2008

Steven Hodson of WinExtra posts what he calls the “From the Pipeline” of the best links of the day. That is a nice concept. It will be great to look back on a year from now as a history of what took place. These are my links for June 1-3. Not all brand new content but on my radar. Heard from the noise.

Excuses, WordPress, & Blogging

For the past 6-8 weeks I have been tech blogging. Well at least a little. I have managed to post sporadically with a quest to post regularly. Sporadically is probably the best I can do for now. I tried blogging before and had given up on it. But this time I think it has stuck. I will maintain this blog and try to post daily but at least once a week.

As a new blogger I have been working to spruce up the site. I have been researching many WordPress themes, many sidebar widgets, and lots of tweaks for the blog. Several months ago I added the Disqus plugin for threaded commenting. Disqus is great! If you do not use it for your WordPress blog you should really give it a try. Installation is easy and it works great. One of my favorite features is the commenting by email reply .

During the past week I have been looking at WordPress themes and wordpress theme development. The main process in a wordpress theme that displays your posts is called “The Loop.” The loop looks like this:

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

//Code here would display and format the post.

<?php endwhile; ?>

All wordpress themes have the_loop but some have more than one. Some premium themes and magazine style themes may also display post excerpts in a sidebar or else where on the page. They have multiple loops. The following is a list of links that I have viewed as I was researching multiple wordpress loops.

I looked at ways to enhance my theme with category pages. I wanted a specific verbiage at the top of each category page. Here are some relevant links:

As I stated I have been looking at many different wordpress themes. It is good to choose a theme and stick with it. Here are couple places to take a look at themes:

I decided on Cutline by Chris Pearson for now. It is a 3 column theme. But I intend to tweak it further by changing the theme’s pages, categories, sidebars, and general setup.

Here a couple more general WordPress links:

One more thing. So you want to play with new themes, or just tweaking your site. One thing you can try is installing WordPress locally. So you do not have a Linux machine? No problem, XAMPP to the rescue.

XAMPP is a free, cross-platform web server, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages.

XAMPP lite contians just what you need. XAMPP is zipped and requires no install. There is even a portable apps version of XAMPP. XAMPP contains everything needed to run WordPress. Check out the following link:

This link gives you step by step instructions to get your local WordPress install up and running.

I like this blogging thing no more excuses but to post.

Tip: Email Address Of Disqus Commenter

I have been using Disqus for comments for about 1 month. I really love it so far. The WordPress plugin was quick and easy to install. I have had absolutely no problems with it.

One thing I could not figure out was if the commenter’s email address was accessible. David over at the KnightKnetwork hunted around and found out that on the Dashboard view of your Disqus profile each comment has an Admin button.

Click the admin button and the email address and IP address of the commenter are revealed.

I love Disqus but here are my top 2 feature requests.

  • I would love for Disqus to intergrate with FriendFeed
  • I would like to be notified of a reply to a comment I made even if it is not on my blog.

Disqus is great keep up the good work.