SmartPORTAL: User login API features
SmartPORTAL allows users to log in to your website using their Raiser's Edge NXT record. This means they can use the various SmartPORTAL forms such as login, profile updates, add action and the callhandler function.
On top of this it also provides a JavaScript based API through which you can use the Raiser's Edge NXT record data for your own purposes - restricting content by memberships, showing record fields to the user (email, name, addressee etc.).
Example code
To accomplish this you need to add to your page an event listener to your page. There is an example below that uses this event listener to indicate if the user is logged in or not:
- <h2>SmartPORTAL Status:</h2><div id="status">Loading status...</div> <script>window.console = window.console || {
- log: function () {}
- };
- document.addEventListener("smartprofile_ready", function (data) {
- console.log(data);
- console.log("Initialised SmartPORTAL LOGIN/OUT CODE RUSI");
- if (data.detail.loggedin) {
- $('#status').html('Logged in as ' + data.detail.constituent.name);
- } else {
- $('#status').html('Not logged in');
- }
- });</script>
In order for this event to fire you must have another SmartPORTAL snippet on the page OR use the snippet from the 'Addons' > 'Login check (and API support)' tab in the editor:
The Event
The event 'smartprofile_ready' is called with data about user. A sample data object is shown below. You can example this in Chrome by adding the above 'Login check...' snippet to a page and logging in as a user. Then open the console (F12 and go to the Console tab) and the 'CustomEvent' object displayed there will have the below object which you can review:
Related Articles
SmartPORTAL - Set up instructions
SmartPORTAL overview SmartPORTAL is a flexible, modular application that allows you to build forms based on your functional requirements. The core SmartPORTAL elements are: Profile update form Login / Register form Add Actions SmartPORTAL allows your ...
SmartPORTAL: API and example populating the form using URL parameters
SmartPORTAL has an API which allows you to hook into events. This allows you to do a lot of different things as you can alter the form or form fields prior to the display of the form to the end user. The JavaScript ...
SmartCALLHANDLER: API and customisation
You can customise SmartCALLHANDLER using our 'hooks' and the 'ST_API' function. Details of this are below. You require knowledge of JavaScript programming and the ability to add your code to the page where you have placed the SmartCALLHANDLER ...
SmartIMPORT: Custom code features
There are two custom code options within SmartIMPORT. First, the 'Start code' block runs at the start of the import process with the spreadsheet row data available. Second, the 'Search code' which runs just after we have searched for a matching ...
SmartPORTAL: Google form protection
We provide support for Google Recaptcha v3 support on your SmartPORTAL forms. To enable, within the CORE settings of the product under the 'Security' tab enter your recaptcha keys. To create the keys you need to: ...