#Overview
WP Fusion uses the Salesforce Object Query Language (SOQL) to search for records in your Salesforce account.
For example when searching for a contact record by email address, loading the tags or topics for a contact, and applying / removing tags or topics from a contact.
Before WP Fusion executes any Salesforce query, the query is passed through the wpf_salesforce_query_args
filter, which allows you to modify the query before it’s sent.
#Parameters
$query_args
(array): The query arguments$method
(string): The API method being performed$searchfield
(string): The value being searched for
The default query arguments, by method, are:
Method: get_contact_id
array( "q" => "SELECT Id from Contact WHERE Email = '{$email_address}'" )
Method: get_topics
array( "q" => "SELECT TopicId from TopicAssignment WHERE EntityId = '{$contact_id}'" );
Method: load_contacts
array( "q" => "SELECT EntityId from TopicAssignment WHERE TopicId = '{$topic_id}'" );
#Examples
#Use a custom email field for contact lookups
By default WP Fusion uses the Email
field for looking up a contact ID. This example changes that lookup field to a custom field on a custom object type, Email__c
:
function custom_wpf_query_args( $query_args, $method, $searchfield ) {
if ( 'get_contact_id' == $method ) {
// In this case the $searchfield is the email address we're trying to get the contact ID of
// The default value of wp_fusion()->crm->object_type is Contact
$query_args['q'] = "SELECT Id from {wp_fusion()->crm->object_type} WHERE Email__c = '{$searchfield}'";
}
return $query_args;
}
add_filter( 'wpf_salesforce_query_args', 'custom_wpf_query_args', 10, 3 );
Was this helpful?
Let us know if you liked the post. That’s the only way we can improve.