Action Mobile Registration

Applications need to be customized for every user’s personal needs, so providing a smooth and simple registration process is one of the essentials of every application. The Appzio platform has a pre-built registration action called Mobile Registration. You can customize it from the admin panel to ask to user for the information your app needs and change the colors and images. However if you want to make more complex changes that you will need to know more about how this action works under the hood.

Registration Phases

When a user is registering in you application you may want him to complete some additional steps, apply preferences or something else. Doing all this on a single screen can be quite overwhelming both for the user and for the developer that will have to maintain the code. This is why the base concept around Appzio’s registration action is separating the logic into different phases.

When the action is triggered, the default tab1() method will be executed. The current phase that the registration is in, is stored in a variable called reg_phase. The controller will check for the current step or it will default to the first.

$this->phase = $this->getSavedVariable('reg_phase') ? $this->getSavedVariable('reg_phase') : 1;

Afterwards, the name of the method that is to be executed will be dynamically generated depending on the phase that the user is in. The method name will consist of the current active theme and the string ‘Phase’ followed by the phase number. If such a method doesn’t exist we check if the phase variable is set to complete. That signals the controller to trigger the registration completion. Here’s an example:

$function = $this->theme . 'Phase' . $this->phase;

if (method_exists($this,$function)) {
} else if($this->phase == 'complete') {

To clarify this better, if your theme is called Appzio then your phase methods must be named – appzioPhase1, appzioPhase2, etc. The main Mobile Registration controller provides you with a lot of functionality that you can use but it doesn’t implement any phases out of the box. You don’t have to follow any particular guideline and there is no limit on the phase count – you can have as much as you like.

It’s important to not forget to save the variable with the current step. This way if the app refreshes he will still be on the step that he has reached, otherwise the controller will return him to the last saved one or default to the first.

$this->saveVariable('reg_phase', 4);

Completing Registration

Once you’ve taken the user through all the phases you must complete his registration. Although there is not a concrete way to do it, if you have a look at how themes are working at the moment you will notice that most of the follow similar patterns.

  1. Save any data that you need or execute logic
  2. Set the reg_phase to complete
  3. Complete the action

You will want to save any variables or data that you have left, then set the registration phase to complete, so the controller knows how to handle it and finally complete the action. The example below shows an example of how this process can be handled. Notice how we clear the scroll and the footer be reinitializing them, thus getting a clear view. Then we can add something to the scroll like a message, image or a gif to indicate the loading of the next action.


// We clean the scroll from all elements attached to it
$this->data->scroll = array();
$this->data->scroll[] = $this->getText('Loading...');
// Also clean the footer
$this->data->footer = array();

// Save data and set phase to complete

// Set action to be completed on load
$complete = new StdClass();
$complete->action = 'complete-action';
$this->data->onload[] = $complete;

return true;