Function for Creating Tables with WordPress Plugins

Here is a very useful function I have written to install/update the database tables in your custom WordPress plugin. Basically I have used the examples given on the “Creating Tables with Plugins” page at

In your main plugin file (ex. my_plugin.php) I define my plugin version:

define("MY_PLUGIN_VERSION", "2.16" ); //Declare the plugin version. This way we know the tables are always up to date. I usually declare this in my main plugin file.

Then in my functions.php file:

function my_plugin_run_install ($table_name, $table_version, $sql) {
		   global $wpdb;
		   $wp_table_name = $wpdb->prefix . $table_name;
		   if($wpdb->get_var("SHOW TABLES LIKE '".$table_name."'") != $table_name) {
				$sql_create_table = "CREATE TABLE " . $wp_table_name . " ( " . $sql . " ) ;";
				require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

			//create option for table version
				$option_name = $table_name.'_tbl_version';
				$newvalue = $table_version;
				  if ( get_option($option_name) ) {
					    update_option($option_name, $newvalue);
					  } else {
					    $deprecated=' ';
					    add_option($option_name, $newvalue, $deprecated, $autoload);
			//create option for table name
				$option_name = $table_name.'_tbl';
				$newvalue = $wp_table_name;
				  if ( get_option($option_name) ) {
					    update_option($option_name, $newvalue);
					  } else {
					    $deprecated=' ';
					    add_option($option_name, $newvalue, $deprecated, $autoload);

	// Code here with new database upgrade info/table Must change version number to work.
	$installed_ver = get_option( $table_name.'_tbl_version' );
	     if( $installed_ver != $table_version ) {
		  $sql_create_table = "CREATE TABLE " . $wp_table_name . " ( " . $sql . " ) ;";
	      require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
	      update_option( $table_name.'_tbl_version', $table_version );

Using the function is quite simple and can save a few lines of code. especially if you need to install several new tables.

Here is an example of database_install.php:

function my_plugin_data_tables_install () {
$table_version = MY_PLUGIN_VERSION; //Call the plugin version.
//Install the first table
$table_name = "my_first_plugin_tbl";
$sql = "id mediumint(9) NOT NULL AUTO_INCREMENT,
	  time bigint(11) DEFAULT '0' NOT NULL,
	  name tinytext NOT NULL,
	  text text NOT NULL,
	  url VARCHAR(100) NOT NULL,
	  UNIQUE KEY id (id)";
my_plugin_run_install  ($table_name, $table_version, $sql);

//Install the second table
$table_name = "my_second_plugin_tbl";
$sql = "id mediumint(9) NOT NULL AUTO_INCREMENT,
	   category_name VARCHAR(100) DEFAULT NULL,
	   category_identifier VARCHAR(45) DEFAULT NULL,
	   category_desc TEXT,
	   display_desc VARCHAR (4) DEFAULT NULL,
	  UNIQUE KEY id (id)";
my_plugin_run_install  ($table_name, $table_version, $sql);

I hope this helps some of the WordPress plugin authors out there.

An easy way to create login panel with jQuery and CSS

Creating Login Panel with jQuery and CSS
Creating Login Panel with jQuery and CSS

Mohit Aneja over at CSS Jockey has created a pretty nice looking sliding login panel using Jquery and CSS. The sliding login panel is similiar to what can be seen on Twitter and few other popular websites. The script looks pretty lightweight, easy to use and is well documented.  I may be using it soon (when I get around to re-designing this site.)

Check it out the full article here:

Continue reading An easy way to create login panel with jQuery and CSS

Most Used and Abused Web Design Trends of All Time

I found the following  post from Web design Ledger to be pretty funny. I have often found my self using reflective text or mirrored objects, flourishes, and using a lot of stock images in a few projects. I even found myself wondering how I could add a picture of a cup of coffee or a background of a desk into some of my personal designs. Throw in some reflective coffee cups on a desktop and you’ve got a pretty kickin design. LOL

Read the full article here: Most Used and Abused Web Design Trends of All Time

WordPress/Website Security Exploits

I have recently seen several websites that I maintain, as well as several that I don’t maintain, hacked by some kind of bot net. It has been a really good learning experience to say the least.

Most of the hacked websites were running WordPress, so my first thought that it was some kind of security exploit in WordPress. Then I was asked to investigate of a few static HTML or PHP driven websites without WordPress installations. All of the hacks were very similar and had their index.php, index.html, and .htaccess files modified. In the index.php and index.html files there was javascript code and iframe virus codes appended to the end of the file that would try to install different variants of badware/malware to unsuspecting visitors. I even seen a file that had stripped out part of the code within the file and replaced it with the malicious javascript and  iframe virus browser exploits. Therefore completely breaking the file (luckily we had a backup of the now broken file and were able to to get the site working again.) Continue reading WordPress/Website Security Exploits

WordPress Events Registration with PayPal IPN

Attention! The plugin has undergone a major reconstruction and name change. The new name of the plugin is Event Espresso.

Event Registration and Management Plugin for WordPress

This WordPress plugin provides a way to take online registrations for events such as conference and seminars that are held live. Events are managed quickly and easily from within the WordPress dashboard.

The plugin also uses the PayPal IPN to record payments to the built in WordPress database. It allows you to capture the registering persons contact information to the WordPress database as well as provides the ability to send the registrar to your PayPal payment site for online collection of event fees. PayPal payments are captured to the database using the PayPal Standard IPN.

Reporting features provide a list of events, list of attendees, and excel export.

Download Plugin | Test Drive | Upgrade to Pro Version | Support Forum

Download Pro Version

Add to Cart View Cart

Version Comparison and Features | More Info | Visit the Forums

If you like this plugin, please consider making a small donation or clicking on a few of the ads displayed on the site.


  1. After unzipping, upload everything in the ‘paypal-events-registration’ folder to your ‘/wp-content/plugins/’ directory (preserving directory structure).
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Go to the Event Registration Menu and Configure Organization and enter your company info – note you will need a PayPal id if you plan on accepting PayPal payments
  4. Go to the Event Setup and create a new event, make sure you select ‘make active’.
  5. Create a new page (not post) on your site. Put {EVENTREGIS} in it on a line by itself.

Note: if you are upgradings from a previous version please backup your data prior to upgrade.

If you have watched the video below and are having trouble installing the plugin or just need additional support. Please visit our “Premium Support” page or view the FAQ below.

Setting up the Plugin

Frequently Asked Questions:
To use, create a new page with only  {EVENTREGIS}

To display list of attendees of an active event use {EVENTATTENDEES} on a page or post.

*For URL link back to the payment/thank you page use  {EVENTREGPAY} on a new page.

*For PayPal to notify about payment confirmation use  {EVENTPAYPALTXN} on a new page.

*This page should be hidden from from your navigation menu. Exclude pages by using the ‘Exclude Pages‘ plugin from or using the ‘exclude’ parameter in your ‘wp_list_pages’ template tag. Please refer to for more information about excluding pages.

Email Confirmations:
For customized confirmation emails, the following tags can be placed in the email form and they will pull data from the database to include in the email.

[fname], [lname], [phone], [event],[description], [cost], [company], [co_add1], [co_add2], [co_city],[co_state], [co_zip],[contact], [payment_url], [start_date], [start_time], [end_date], [end_time]

Sample Mail Send:

***This is an automated response – Do Not Reply***

Thank you [fname] [lname] for registering for [event].  We hope that you will find this event both informative and enjoyable.  Should have any questions, please contact [contact].

If you have not done so already, please submit your payment in the amount of [cost].

Click here to review your payment information [payment_url].

Thank You.

Save 30,000 for WordCamp Campaign

Event Listings and Registration Pages
Event Listings and Registration Pages
Attendees and Payments
Attendees and Payments
Screenshot of Events Registration with IPN Pro
Screenshot of Events Registration with IPN Pro using the Calendar (Pro Version)
Event Setup Options
Screenshot of some Event Setup Options (Pro Version)
Events and Payments
Events and Payments

If you haven’t noticed, the WordPress plugin “Events Registration with PayPal IPN” is no longer available for download on We found some serious security issues within the plugin (mostly deprecated WordPress database functions) so we decided it best to go ahead and remove the plugin until security was improved.

After a major overhaul of the back-end code we have re-released the plugin under a new name (Advanced Events Registration) and have also released a pro version of the plugin with many additional features.

It is highly recommended that you upgrade to the latest version of the Advanced Events Registration plugin ASAP.