Archive for August, 2008

PHP $_SESSION in Wordpress

Thursday, August 21st, 2008

I was recently writing some code for an application based on Wordpress when I realised that I would need to retain data across pages. Naturally, I opted to use PHP session handling. A quick search for the string ‘_SESSION’ suggested that Wordpress does not use the $_SESSION superglobal array. Therefore, if you are going to simple user $_SESSION in your code, you will need to place session_start(); somewhere in the code, either in a core Wordpress include file, a plugin file or in a specific file(s).

Finally, if the session handling is used as part of the Wordpress administration backend, you will probably want to terminate the session when the user logs out. To achieve this, you can simply create a function that destroys the session and call this function during the ‘wp-logout’ hook.

function clear_session() {
session_destroy();
}

add_action(’wp_logout’, ‘clear_session’);

Using Wordpress as a Forum

Saturday, August 9th, 2008

I was recently asked to set up a basic forum system for a client. They were using Simple Machines Forums, but it wasn’t working smoothly. Rather than trying to address the issue, I opted to try out the bbPress forum software based on Wordpress. The two main reasons were: (1) its simplicity (2) the fact that it is based on Wordpress, which my client’s are already familiar with. So I installed it and liked the simplicity and elegance of the system. However, one problem with bbPress relative to my client’s needs, was that there is no way to upload images and insert them into posts.

Now, knowing that Wordpress has a nice little WYSIWYG editor with an associated image uploading and insertion feature, my first thought was to try and hack bbPress by migrating in the Wordpress editor. I spent a small amount of time trying to achieve this with little apparent success. Instead of continuing down this path, I started to think about the possibility of making a few modifications to Wordpress to get it to act more like a forum. Fortunately, a quick Google search later and I found that someone had already created a theme and plugin combination for Wordpress which does this very thing.

The theme (TDO Forum Wordpress Theme) can be found at http://thedeadone.net/software/tdo-forum-wordpress-theme/ and the plugin (TDO Mini Forms Wordpress Plugin) can be found at http://thedeadone.net/software/tdo-mini-forms-wordpress-plugin/.

URLs in Joomla

Friday, August 1st, 2008

I recently completed a Joomla/VirtueMart e-commerce system for some friends, Cradle of the Soul. At the outset of the project, I knew that I would have to address the issue of Joomla’s ugly, complex and search-engine unfriendly default URL structure. Some brief searching for resources on the topic led me to a great little series of articles on the options available regarding Joomla URLs. If you head over to http://www.alledia.com/blog/joomla-urls/, you will find at the bottom of the list links to the 6-part series.