Article Contents Related Articles Tags Was This Helpful? Last Updated
  • 2012/07/09

Example: Auto–Login User After Registration

By default, Member Guardian will not automatically log users into their newly created account following a successful registration. This custom action circumvents that and automatically logs a user into his/her account.


Create and save a file with the following code to your local hard drive. Save it as "post_reg_auto_login.php".

include_once $options['ppsd_fsp'] . "/functions/login_function.php";

Create the Custom Action

From your Member Guardian admin control panel, click on "Settings » Add a Custom Action" and input the following settings:

FieldInputted Value
NamePost-Registration Auto-Login
TypePHP Code Inclusion
TriggerRegistration Complete
File LocationUpload the File
Upload FileSelect the post_reg_auto_login.php file created above
Upload ToN/A
Registration FormSelect a registration form from the list only if you want to limit this custom action to a specific registration form.

Save the changes. Users will be automatically logged into their new accounts when they complete their registrations!

Some Things to Remember

The default "Registration Complete" template will send the user to the login page after a successful registration. So although the user is logged in, it might not seem like it. I recommend updating the Redirect setting on your registration forms to redirect the user to the member control panel to avoid this ( You can edit this setting by editing any form from "Settings » Registration Forms".

Tags: #custom_actions