Monthly Archives: April 2015

WordPress with Ultimate Client Manager

Ultimate Client Manager (UCM) is a Project Management tool designed for managing tasks and invoicing. This product offers the flexibility of customization to suit individual business needs.
I got an opportunity to work on a proof of concept where the intent was to establish the theory into practice. After studying their documentation, I chose to write a simple script to create a job inside of UCM, set the status to ‘New’ and Start Date as ‘Today’.
<?php
chdir('/path/to/ucm/');
include('init.php');
$job['name'] = 'Demo';
$job['status'] = 'New';
$job['date_start'] = date('Y-m-d');
$new_job_id = module_job::save_job('new',$job);
$new_job = module_job::get_job($new_job_id); //get values from newly created job
echo 'new job id:'.$new_job_id.' created with job name:'.$new_job['name'];
?>

Executing this code will insert a new job in UCM and the results will be echoed to the browser. I will be scaling this script as per my project requirements and most likely hook this to WordPress. But this can be used with any other platform.
Hope this helps! I will be writing more on this in future.

HTML table sorting with DataTables

I had this opportunity to use the brilliant DataTables jQuery plugin to sort an html table in a formidable pro view to display data. Primary benefits to using this plugin are:
a) Lightweight.
b) Easy to install and initialize.
c) Adds dynamic search and pagination features by default. However, this can be altered by passing parameters during plugin instantiation.

However, I would like to get an opinion if there are better and more efficient ways to sort html tables. I did some research but finally came back to DataTables to implement my custom solution. Please leave me a comment and let me know.

Autocomplete in Formidable Pro

Formidable Pro offers a fine feature called ‘enable autocomplete‘ for drop-down fields, the team making an extremely intelligent and efficient use of Chosen to drive this new field option.
However, one demerit of this feature is the lack of mobile support, ‘overkill’ being cited as one of the reasons for desktop only support and I respect their decision and whoever voted in favor of the cause.
This made me decide to implement my own custom solution with plain old jQuery and a text field (instead of drop-down). My requirement is to drive a ‘Data From Entries‘ field with ‘enable autocomplete’ checked for users to look up the values as they type. Also, users should be able to submit the data even if they enter a value not present in the drop-down, the new value finally getting added to the drop-down list.
As a first step to solve the problem, I added a text field to the form and bounded it to jQuery autocomplete. Second step was to write some PHP to make it the remote data source for autocomplete script. I used Formidable API to collect and return all field values from the form that was supposed to be the source for my data from entries field. This made my text field behave as a drop-down and also enabled users to add new values to the list. On form submission, I used Formidable hook to add the new entry to the list of entries.
A small demo is attached, the values you see are Formidable entries. Hope this helps! Please leave me a comment and let me know if there is a better way to achieve the same result.

Secure Page behind WP log in

Steps to quickly secure a page behind WordPress login are:
1) Open the page template you are using to display the page in text editor.
2) Add the code block below just beneath the template name
<?php if(is_user_logged_in()){ //check if user is logged in ?>
3) Go to the end of the template and add the below code
<?php } else { wp_redirect(wp_login_url(get_permalink())); //Redirect to login page} ?>
That’s it. Your page is now secured behind a login. Hope this helps! Please leave a comment and let me know if there is a better way to achieve the same result.