How To Create A Simple (Database Using) WordPress Plugin – Sample Code

At the January meeting of Web414 at Bucketworks, Jeramey gave a presentation on how to create a simple WordPress plugin. The plugin supports adding and listing members of the Web414 community using jQuery (AJAX).

The code is available to download in a super small zip file (

  1. It can be installed by uploading it to your “wp-content/plugins” folder, and activating it from your WordPress dashboard.
  2. It will require the creation of a database table in your WordPress database. You can see the structure of how to do that in included file (web414.php), and grab the code to copy and paste into PhpMyAdmin (if you like things quick and easy).
  3. To make the plugin appear on your site you will need to include two different shortcodes on any of your pages. They are “[add_web414member_finished]” and “[list_web414_members]”. Put them on any page and after activating the plugin they will appear. The add a member function will only appear to logged-in users.
  4. Extend this as you wish.

Let me know if you have any questions or comments, we would be happy to help you get starting writing WordPress plugins.

7 comments to How To Create A Simple (Database Using) WordPress Plugin – Sample Code

  • hey bro
    d above code has an error
    when i active d plugin it show me error like dis

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1]
    SELECT name, coolness FROM

  • @mITesh – You need to use the database table creation information in the plugin file first.

  • Jeff


    How do I edit the code so that I can add members without being logged in?

    I was about to get the form to show without logging in, but can’t INSERT data into the table unless I am logged in???

    Any insight is appreciated.


  • @Jeff

    Sorry for the slow reply.

    There is a line – add_action(‘wp_ajax_add_414member_process’, ‘add_414member_process’);. You will need a second line “add_action(‘wp_ajax_nopriv_add_414member_process’, ‘_add_414member_process’);”

  • Arun


    Can you please explain the 3rd step. as am new to this wp.

    Thanks in advance.

  • @Arun

    Place those shortcodes on two different pages on your site. Copy and paste them with the brackets right into the WordPress editor and publish the page.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>