Plugin / RHJ4 Notifications



RHJ4 Notifications and its sibling, RHJ4 Diagnostics solve problems that have plagued programmers for years: How to communicate with users in a clean, clear and visually consistent fashion regardless of where in the program the message originates.

A notification message can be sent from jQuery code in the browser or from PHP code in the server. Either type of message can be displayed immediately or queued for display after the next page turn.

Notifications appear as popup messages on the bottom right corner of the screen and can stay on the screen until the user clicks on them or they can disappear after five seconds.

Using this plugin, a message can be sent easily from a single line of PHP code:

    rhj4_notification('Warning! Danger, Will Robinson!', NOTIFICATION_TYPE_WARNING);

The same messsage can be sent from jQuery code running in the browser:

    jQuery.notification('Warning! Danger, Will Robinson!',

By default, notifications will disappear from the screen after five seconds; however, to make a notification “sticky”, add true as the third argument to either the PHP or jQuery functions:

    jQuery.notification('Warning! Danger, Will Robinson!',
    jQuery.notification.type('warning'), true);

Notifications can be displayed immediately or queued in the wp_notifications table for display later. The wp_notifications table is created when the plugin is enabled. To “enable” this plugin, see Settings and click on the “Enable” checkbox.

RHJ4 Notifications supports 15 types of notifications


A notification consists of a:

  • Message – some text to be shown to the user.
  • Notification Type – an integer in the range -1..13 that indicates the style of the notification.
  • Sticky – a boolean that indicates whether the message should disappear after a few seconds or “stick” around.

Notification Types

These constants are in the global name space:


There are four different interfaces available in the Notifications plugin:

  • Global Functions
  • Class Methods
  • jQuery plugin
  • Short Codes

PHP Global Functions

Generate a notification

rhj4_notification($message, $type = NOTIFICATION_TYPE_MESSAGE, $sticky = FALSE);

PHP Class Methods


Return an instance of this plugin. This usage allows code in multiple places to use the same instance without having to reinitialize the plugin every time.


    $myInstance = RHJ4Notifications::instance()    


Initialize plugin using any of the options defined in $args (see “options” for a list of supported options).


Kill the current instance.


Activate this plugin.


Deactivate this plugin.

options ($options = null)

Validate options and return valid array. The supported options are:

enable: enable generation of diagnostic messages.

log = {true|false}: enable log notifications

system = {true|false}: enable system notifications

error = {true|false}: enable error notifications

warning = {true|false}: enable warning notifications

confirmation = {true|false}: enable confirmation notifications

message = {true|false}: enable message notifications

test = {true|false}: enable test notifications

data = {true|false}: enable data notifications

comment = {true|false}: enable comment notifications

tip = {true|false}: enable tip notifications

reminder = {true|false}: enable reminder notifications

date = {true|false}: enable date notifications

validation = {true|false}: enable validation notifications

timer = {true|false}: enable timer notifications

set($options = NULL)

Establish default options and save them in wp_options. See “options” for a list of supported options.


Reset options to their default values.


Enable this plugin. This function requires admin privileges and should only be called when setting up a site. It creates a database table (first deleting if if it exists) that stores queued notifications.

This function can be accessed from the settings panel or called directly in your code.

All notifications are stored (temporarily) in a common database table that is keyed by Session ID.

save($message_text, $message_type = 1, $is_sticky = 0)

Save a message for display on next page turn or explicit call from jQuery.

 @param int $message_type
 @param bool $is_sticky
 @param string $message_text

delete_user_notifications ($user_id = null)

Delete all notifications for $user_id.

delete_session_notifications ()

Remove all notifications for the current session.

delete_all_notifications ()

Clear notifications table of all pending notifications.


list_user_notifications($delete = TRUE)

Return list of all notifications pending for $user_id.


list_session_notifications($delete = TRUE)

Return a list of all pending notifications for the current session.

list_all_notifications($delete = TRUE)

Return a list of all notifications.

jQuery Plugin API

The jQuery code included in this plugin is implemented as a jQuery plugin with the class name of “jQuery.notification”.

The functions supported by this class are:

notification(message, type, isSticky, pluginurl)

message (required) may be a string or an object.

If it is a string, the string is the notification text to be displayed.
If it is an object, the object may contain properties corresponding to any of the options supported by the jQuery.options method.

_type (optional) indicates the notification type as either a string or an integer. If missing, type will use the current option.type value.

_isSticky (optional) indicates whether the notification is sticky. If missing, isSticky will use the value from msgType.

_pluginurl (optional) indicates the url to be called by this function to communicate with the server. If missing, the code will search for a hidden field named #hid_plugin_url.


    jQuery.notification('This is a notification',3,true);

    jQuery.notification({ notification: 'This is a notification', 
            type: "data", 
            sticky: true, 
            queue: false });


Returns an object containing the default values of all options used by this plugin:

    version: version,   //  code version
    type: 'log',        //  default message type
    sticky: true,       //  if true, don't clear the message automatically
    queue: false,       //  If true, queue the message for later display
    class: '',          //  jGrowl class that styles this message
    clear: true,        //  Delete saved messages after showing them
    showOnConsole: true,//  Show a copy of the message on the console.log
    glue: 'after',      //  jGrowl property that controls order of displaying messages
    sleep:,             //  sleep in milliseconds before displaying message 
    closeTemplate:      //  image to use in close template
    header:             //  '<span class="icon"></span>',
    notification: ''    //  Message can be included with options


Set notification sleep delay in milliseconds. This value will be remembered by all subsequent calls to $.Notification.

option (key, value)

Get/Set single option:

-version: (read only)
-type: notification type (string or number)
-sticky: boolean
-queue: boolean – save messages in database until explicit request to drain queue
-clear: boolean – clear queue

save (message, code, sticky, handler)

-message: the notification text

-code: notification type

-sticky: stick around for awhile or scram

-handler: (optional) custom function to handle displaying the notification.

messageType (code)

Returns array of messageType objects.

type (type)

Validate notification type value


Get current session id.


Return URL of AJAX handler function.

queue (handler)

Return count of notifications awaiting delivery.

show (clear)

Show all messages in the queue. If clear===true, delete all messages just just retrieved.


Close any open notification messages on screen.


Delete all messages to the current session.

showUser (userId)

Notifications can be sent to a specific userId. The messages will be held until that user logs in.

clearUser (userId)

Delete all user notifications from database.

Short Codes

  • enable=1,3,6 will enable notification types 1,3 and 6.

  • notify message= type= sticky={true|false}

  • verbose will cause actions to be echoed on the page.

  • demo will display a demonstration of using the Notifications plugin.


I will attempt to answer your email as quickly as I can, but cannot promise immediate response.

I will entertain ideas for enhancements, especially if I hear the same request from multiple people.

Donations will encourage my support… and my thanks.


I make my living by helping WordPress developers. If I can help you, please contact me.

Bob Jones


0 reviews

Rating breakdown

Details Information



First Released

18 Sep, 2010

Total Downloads


Wordpress Version

3.0.1 or higher

Tested up to:


Require PHP Version:




This plugin has been closed.


The plugin hasn't been transalated in any language other than English.


The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.