Flat 15% OFF starting from one instance! Sale Ends on 12 October 2025
Claim Now
Developer Hooks & Filters
The Object Data Sync for Salesforce plugin provides several WordPress hooks that allow developers to customize and extend the plugin's functionality during the record synchronization process between Salesforce and WordPress.
This page covers the available action hooks and filters you can use to modify sync behavior, transform data, and add custom functionality.
Available Hooks
1. mo_sf_sync_after_object_upsert
Hook Type: Action Hook
Description: Fires after a Salesforce record has been successfully synced (inserted or updated) in WordPress. Use this hook to perform post-sync operations such as logging, triggering workflows, or updating related data.
When It Triggers: Immediately after the WordPress record has been created or updated based on the Salesforce data.
Parameters:
$wp_object
(string) - WordPress Object Type (e.g., 'post', 'user')$wp_upsert_object_id
(string|int) - WordPress Record ID that was synced$sf_object
(string) - Salesforce Object Type (e.g., 'Contact')$field_map
(array) - Field mapping configuration used in this sync$record
(array|object) - Complete Salesforce record data
Hook Definition:
/**
* Fires after the Salesforce record has been synced to WordPress.
*
* @param string $wp_object WordPress Object Type (e.g., 'post', 'user').
* @param string|int $wp_upsert_object_id WordPress Record ID synced.
* @param string $sf_object Salesforce Object Type (e.g., 'Contact').
* @param array $field_map Field mapping used in this sync.
* @param array|object $record Salesforce record received from Salesforce.
*/
do_action( 'mo_sf_sync_after_object_upsert', $wp_object, $wp_upsert_object_id, $sf_object, $field_map, $record );
Example Usage:
add_action( 'mo_sf_sync_after_object_upsert', 'custom_post_sync_operations', 10, 5 );
function custom_post_sync_operations( $wp_object, $wp_id, $sf_object, $field_map, $record ) {
error_log("Salesforce {$sf_object} record (ID: {$record['Id']}) synced to WordPress {$wp_object} with ID {$wp_id}.");
}
2. mo_sf_sync_pre_data_send
Hook Type: Filter
Description: Allows you to modify the data received from Salesforce before it is saved to WordPress. Use this filter to sanitize, transform, or augment WordPress field values before insertion or update.
When It Triggers: After Salesforce data has been mapped to WordPress fields, but before creating or updating the WordPress record.
Parameters:
$data_to_store
(array) - Associative array of WordPress fields and their values
Returns: (array) Modified data array to be saved to WordPress
Hook Definition:
/**
* Filter the record data before saving to WordPress.
*
* @param array $data_to_store Associative array of WordPress fields and their values.
* @return array Modified data array to be saved.
*/
$data_to_store = apply_filters( 'mo_sf_sync_pre_data_send', $data_to_store );
Example Usage:
add_filter( 'mo_sf_sync_pre_data_send', 'normalize_phone_number' );
function normalize_phone_number( $data ) {
if ( isset( $data['phone'] ) ) {
$data['phone'] = preg_replace('/\D+/', '', $data['phone']);
}
return $data;
}
3. mo_sf_sync_after_date_conversions
Hook Type: Filter
Description: Allows you to modify or transform a date value (in Y-m-d format) received from Salesforce before it is saved as WordPress metadata. Use this hook to adjust date formats, apply timezone changes, or convert DateTime objects.
When It Triggers: After a valid Y-m-d date string from Salesforce has been parsed into a DateTime object, but before the value is saved as post/user/custom post meta in WordPress.
Parameters:
$dt
(DateTime) - Parsed DateTime object from a Salesforce date field
Returns: Modified (mixed) date value to be saved. You can return any format suitable for saving as a meta value
Hook Definition:
/**
* Filter a parsed DateTime object from a 'Y-m-d' formatted string before saving it to WordPress.
*
* @param \DateTime $dt Parsed DateTime object from a Salesforce date field.
* @return mixed Modified date value to be saved. You may return:
* - A formatted string (e.g., with timezone or localized)
* - A DateTime object
* - Any format suitable for saving as a meta value
*/
$new_value = apply_filters( 'mo_sf_sync_after_date_conversions', $dt );
Example Usage:
add_filter( 'mo_sf_sync_after_date_conversions', 'convert_date_to_display_format' );
function convert_date_to_display_format( $dt ) {
return $dt->format( 'F j, Y' ); // e.g., "July 17, 2025"
}
Note: These hooks provide powerful customization options for developers who need to extend the plugin's synchronization behavior. Always test your custom implementations in a development environment before deploying to production.
For more information visit our Object Data Sync for Salesforce page or mail us at salesforcesupport@xecurify.com.