DOCUMENTATION

ft_api_login

This function logs a user in programmatically. It takes a single parameter: a hash with these keys:

Required keys

  • username (string)
  • password (string)

Optional keys

  • auto_redirect_after_login (boolean, defaulted to FALSE)
  • login_url (string) the URL to redirect to after logging in

Return Values

The return values first depend on whether the $g_api_debug value is set. It if is, nothing is returned for errors: they are displayed in the browser. If not, the function has the same return value pattern as the other functions: it returns an array with 2 indexes. The first is a boolean, indicating whether the login was successful or not. The second is the unique error code, or the empty string when successful.

If the auto_redirect_after_login key is passed to the function (and set to true), the function will not return any values on login: it will automatically redirect to the appropriate login page specified by the individual user account settings. This login URL can be overridden if you pass the extra login_url key.

Here's an example of how it can be used:

This will log the user in, but not redirect anywhere - you can continue processing PHP statements after the ft_api_login() call. Important: make sure that this page has started sessions! Form Tools requires sessions to have started in order to store the login information for the duration of the users "stay" in Form Tools.

This will automatically log the user in, if successful. They will be redirected to their custom login page, defined in their user settings.