Notification System for Membership Websites Using Formidable Pro

I am sharing here my experience of building an announcement system based on Formidable Pro (currently at version 2.14).

The notification system is created for membership websites where admins can send personalized notifications to single or multiple users.

Components:
1. The form is a simple form with a textarea and 2 checkboxes. Leave the checkboxes empty but check the “Use separate values” checkbox in their properties
Capture1

2. The admin view and page will allow admins to create, edit and delete notifications
Capture2

3. The public view will allow recipients to read and “mark as read” the notifications
Capture3

4. The custom code that is explained below:

Populate user fields (Recipients and Read by in my case or field_id 124 and 212)

After adding this snippet to your functions.php file in your active theme you will get prepopulated checkboxes with current users registered for the subscriber, s2member_level1 and administrator roles. Of course you will use any number of roles you like or all existing users, just format properly the WP_User_Query

Filter the notifications view so that only notifications sent to current user will be displayed

Of course, a notification can be sent to several users at once. We need to filter entries that have current user id in the recipients list

You notice the mysql function call fn_parse_ser_array that is a custom made function. You need phpmyadmin access and rights to create functions on your database. This function is the mysql version of the PHP function unserialize.

You may try this mysql command:

Also, we would want to hide the notifications that recipients have already marked as read. First idea is to use a negate condition on field 212 but… it does not work. In fact

would work on its own but this will never work:

Therefore my solution was to hide the read notifications in the table itself by using DataTables jQuery plugin

Mark as read system for notifications

This system will both hide notifications for users that read them and will show admins who actually read their notifications

First add this snippet to functions.php file then add the [mark_as_read entry_id='[id]’] shortcode into the last column of the notifications table inside the view

Note that the attempt to use Formidable API failed in this case because instead of this new value [1,2,3] it will always insert this new value ‘[1,2,3]’ messing the checkbox values in the database… (maybe this is a Formidable but at this moment). So I had to copy the behaviour and hardcode it in the last line.

In the datatables initialization we need to add the searchCols filtering as in the next example:

Download

Below you can copy this exported definition of the form and views for your reference and save it as xml file, then import it into Formidable plugin. Please check the fields id that may change, also in the previous section I translated Mark and Read, in the original definitions they are in Romanian language

Reply

Your email address will not be published. Required fields are marked *

2 + = 11

Recommended Articles

Acest site folosește cookies, continuarea utilizării sale înseamnă acceptarea folosirii lor... Mai multe informații

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close