How You Use the pre_pta_decode Hook

The pre_pta_decode hook lets you write custom PHP code, which is executed after accepting the PTA string from the URL and before calling the login routine.

After the hook runs, the p_li parameter is processed and passed to the PTA controller. The hook also passes the redirect parameter so you can modify the location where the customer is directed.

It is not possible to return a custom error message from this hook, so if you want to cover the situation of an interrupted PTA login, you must add a header() location redirect and exit() in your hook. There are two data formatting options: string or array.

  • String format—After the hook executes, the login integration data that was passed to the hook is evaluated to see if it is still a string. If it is, the data is assumed to be a standard base_64 encoded string. An algorithm is run to convert the string into an array of contact pairdata in key->value pairs. This allows the pass-through authentication to work as it would if no hook handler is defined and no extra encryption is added.

  • Array format—After the hook executes, the p_li parameter is evaluated to see if it has been converted to an array. If so, the format of this array is assumed to be the contact pairdata key->value structure. Here’s an example of this structure.

array(
   [p_passwd]=>
   [p_userid]=>username
   [p_email.addr]=>email@example.com