Boost online registration with wordpress Simpler Registration Form Plus Plugin
Syllogic consultants champions a future where integral sustainable development is the norm, not the exception.

Boosting Registration forms

In a recent project we had to make a custom registration form with a various dynamic categories loaded on the form from which a new user can select using a radio button.

Simpler Registration Form Plus

We discovered the wonderful plugin which is the Swiss-army plugin for registration forms.  Why do I call it the Swiss-army of registration forms?  Simply because the author seems to have thought of all the possibilities.  To start with, the form automatically creates the additional user meta fields inside your WordPress installation for any elements you create in the registration form, hence ensuring that your logged-in users have all the extra registered fields integrated into their profile.

The other beautiful aspect is that it is allows for users to view and edit their profiles using a separate [profile_page] shortcode provided by the plugin and you can independently identify which of the fields should be visible in the profile page.

Video tutorial

The plugin comes with an embeded video tutorial which comes quite handy initially to figure out how to display the custom registration form using the shortcode provided.

Callback function for more customisation

Recently the fully loaded commercial version of the plugin was released to the WordPress community (blessings on the author for his next life-time for this good karma :) and it comes with an additional functionality that allows for a custom field to be added to the the registration form (select type = Callback) which call a user defined function to determine the shade and content of that field.  Brilliant I hear you say?  Sure it is.

How to get it to work is a little more complex to figure out since the documentation is thin if not non-existent…hence this post actually.

When you add a new field, selete the ‘Callback’ type and in the option field, enter the name of your function, for example… echo_registration_categories the plugin will call your function with 1 argument, the value of the field saved in the database… this is in order to ensure the field is pre-populated when loaded on the profile page for example.  Here is an example,

//display registration categories in sign up form
function echo_registration_categories($args){
   //let's get the categories for this conference
   $categories = array();
   $categories[name] = get_option("conf_registration_categories_name");
   $categories[currency]= get_option("conf_registration_categories_currency");
   $categories[early_bird_fees] = get_option("conf_registration_categories_early_bird");
   $categories[full_fees] = get_option("conf_registration_categories_full");
    
   $today = strtotime(date('d M Y'));
   $earlyDate = strtotime(get_option("early_bird_date"));
   $isEarly = ($today<=$earlyDate);
  // if($text)
   $output ='<div id="css-user_category" class="option-field radio ">';
   $output .='  <label for="user_category">Registration category<span class="required">*</span></label>';
   $output .='      <ul>';
   $userCategory =$args;
   if ( empty($args) && is_user_logged_in() ) {
      $user_ID = get_current_user_id();
      $userCategory = get_user_meta($user_ID, 'user_category', true);
   }
   for($idx=0; $idx < sizeof($categories[name]); $idx++){
      $checked = '';
      $text = $categories[name][$idx];
      if($text == $userCategory) $checked = 'checked';
      $cur = $categories[currency][$idx];
      $cost = $categories[full_fees][$idx];
      if(  $isEarly ) $cost = $categories[early_bird_fees][$idx];
      $output .='<li><input name="user_category" '.$checked.'  value="'.$text.'" type="radio">'.$text.' <span class="category-cost">'.$cost.' '.$cur.'</span></li>';
   }
   $output .='      </ul></div>';
   echo $output;
}

As you can see, the above outputs a list of radio input elements for a conference registration category.  The user value is passed as the argument $args when the field has a value saved in the database.  I have also added a check for getting the currently logged-in user’s value in case we want to call this function separately outside the context of the plugin….and that piece of code could be left out.

Want to share your thoughts?

Leave a Reply

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