Contacts
Use this API to create, update and delete contacts.
If you are just looking to create forms that collect contacts in a secure manner, it is recommended that you use the forms:form control with the contactmode attribute.
Security Warning: With great power comes great responsibility. This API is for experienced developers to query data from the contacts component. Customer data is sensitive, so you must take great care not to introduce a data leak or vulnerability.
Security Warning: You can retreive contact data via functions such as get() and getAll(). This can be displayed on a public website through the use of a repeater or varDump().
Security Warning: This API also allows you to save customer data. Ensure that if updating existing records, any supplied contact_id is validated so only the intended contacts can be overwritten.
Methods
Invoke via \Components\Customers\Contacts::method()
Click a method name to copy it.
Determines whether a company name is really just the contact's own name.
Accounting and CRM systems routinely mirror a person's display name into their company field (QuickBooks Online, Xero, MYOB, PracticeManager and Mindbody all do this), so a company name equal to the person's name identifies no employer. Treating it as one produces a second contact indistinguishable from the first.
Compares case-insensitively and ignores comma and whitespace differences, so "Zamora, Andrew" matches "Andrew Zamora". Matching is exact, never substring, so a genuine trading name such as "Andrew Zamora Consulting" is still a real company.
Return
True when the company name is just the person's own name
Returns the current contact logged in
Returns a HTML formatted address for the contact
Return
Contact's full address
Returns the id of the contact currently logged in
Parameters:
- $bTrackingFallback
mixed
Returns the country of the current contact
This function will always return a country code as it will fall back to the user's
GeoIP location if not logged in.
Returns the email address of the contact currently logged in
Gets the user's full name
Return
Contact's first and last names as a concatenated string
Retreives an attribute for the current user
Return
Value of the attribute
Returns whether the user is fully registered or not
Return
true if the user has a password, else false
Returns whether or not the user is logged in.
Parameters:
- $bTrackingFallback
mixed
Return
true if logged in, else false
Returns whether the user logged in this session or not
Return
true if logged in this session, else false
Returns the username to pre-fill login forms with: the loaded contact's email, else the last successful login username this session.
Return
Username suggestion, or an empty string
Logs out the current user
Sets an attribute for the current user
Suggests a unique username based on the users name
Returns the raw rows dbGetAll() would return as an iterator, without building them all into an array
The dbGetAll() counterpart of getAllIterable(), for scans over every stored row of a large table (eg: the site-wide content scans in \Framework\Developer\Refactoring). Rows are as stored - JSON fields are not decoded - and are not entity-cached. Because it bypasses getAll(), components that override getAll() are iterated; search queries and components overriding dbGetAll() are refused.
Returns all the columns this component supports
Gets a record from the database
Parameters:
- $iContactId
int
A record's contact_id
Return a set of records from the database
Returns all contact records for a given email address
Returns the entities getAll() would return as an iterator, without building them all into an array
For result sets too large to hold as arrays (eg: every recipient of a marketing send) - only the database driver's compact buffer of the result is held, a fraction of getAll()'s memory. Runs the same SQL as getAll(), and runs it now, as getAll() would; rows are decoded as you iterate.
Search queries are not supported, rows are not entity-cached, and components that override getAll() or dbGetAll() (eg: merging in defaults) are refused rather than iterated without their extra rows.
Gets a single field from a record
Parameters:
- $iContactId
int
A record's contact_id
Returns the number of records in the database (matching the filter if specified)
Returns the contact id from an email address
Deletes a record from the database
Parameters:
- $iContactId
int
A record's contact_id
Return
Returns true if record existed and was deleted, otherwise false
Assumes the role of a user for segment
Resumes the role of the previous impersonation
Parameters:
- $bTrackingFallback
mixed
Parameters:
- $bShowEmailMarketing
mixed
- $bShowAdministrators
mixed
Saves a record into the database
Saves a specific column of a row into a database
Parameters:
- $iContactId
int
A record's contact_id
Return
Array of
Contacts that match the search query.
Returns an array of all possible contact_title / salutation values (Mr., Mrs., etc.)