Login Forms

By editing the settings of a page, you can specify that access should be restricted to contacts who meet certain conditions (more here). Automation can be used to place contacts into groups after form submissions, and you can add a password field to signup forms to allow contacts to set a password.

You can also code your own login forms and restrict access to certain pages or content if you wish. The following article shows a typical implementation of a login form on a Oncord powered website.

Determining Whether a User is Logged in

The <logic:if> control allows you to check whether a user is currently logged into the website. This will allow us to display different content to users, depending on whether they are logged into the website.

<logic:if test="\Components\Customers\Contacts::currentIsLoggedIn()"> <p>Content to display if the user is logged in</p> </logic:if> <logic:else> <p>Content to display if the user is not logged in</p> </logic:else>

The Login Form

The following code is a common implementation of a login form, wrapped in the above <logic:if> tag to determine whether a user is logged in:

<logic:if test="\Components\Customers\Contacts::currentIsLoggedIn()"> You are currently logged in as <strong><personalisation:fullname /></strong><br /> <br /> If you would like to change your login information, please choose from the options below.<br /> <br /> - <a href="/community/profile/">My Profile</a><br /> - <a href="/community/logout/" onclick="return confirm('Are you sure you wish to logout?\n\nYou only need to logout if you are using a public computer and are concerned about your privacy.\nUnlike some sites, this site does not require you to logout after each session.');">Logout</a> </logic:if> <logic:else> <forms:form contactmode="login"> <forms:editbox placeholder="E-mail" validations="mandatory,email" id="contact_email" /> <forms:password placeholder="Password" validations="mandatory" id="contact_password" /> <forms:submitbutton value="Login" /> </forms:form> <br /> <a href="/community/lost_password/">Lost / Forgot Password</a> </logic:else>