Timestamp issue when syncing to Hubspot
-
Hi,
Im having a problem syncing date fields to Hubspot from WP Fusion. I have made sure the field is ‘date’ in the Contact Fields section. An example of the problem in the log is:
membership_startdate: 1630368000000 → 163036800000000
It seems like the wpf_format_field_value is adding extra zeros. The actual error message for this was:
Error while updating meta data: Property values were not valid
163036800000000 is more than 1,000 years ago or 1,000 years from now.These are the following filters I have regarding dates in my functions.php file:
/* WP FUSION FILTERS AND FUNCTIONS */
function my_wpf_filter_registration( $user_meta, $user_id ) {
if ( isset( $_POST[ ‘membership-expiry’ ] ) ) {
$user_meta[ ‘membership_enddate’ ] = $_POST[ ‘membership-expiry’ ];
}return $user_meta;
}
add_filter( ‘wpf_user_register’, ‘my_wpf_filter_registration’, 10, 2 );
function my_watch_meta_field( $fields ) {
$fields[] = ‘membership_enddate’;
$fields[] = ‘membership_startdate’;
$fields[] = ‘membership_name’;
$fields[] = ‘member_since’;
$fields[] = ‘role’;return $fields;
}
add_filter( ‘wpf_watched_meta_fields’, ‘my_watch_meta_field’ );//AND
function save_pmpro_level_to_meta( $level_id, $user_id ) {
//get level information and post it to meta.
$membership_data = pmpro_getMembershipLevelForUser( $user_id );$membership_id = $membership_data->ID;
$membership_name = $membership_data->name;
$membership_startdate = date( ‘d/m/Y’, $membership_data->startdate );
$membership_enddate = $membership_data->enddate;if ( empty( $member_since ) ) {
$member_since = date( ‘d/m/Y’, $membership_data->startdate );
}// convert to date if not 0.
if ( ‘0’ == $membership_enddate ) {
$membership_enddate = ‘0’; //can change this to say ‘Never’ instead.
} else {
$membership_enddate = date( ‘d/m/Y’, $membership_enddate );
}//update the user meta now.
update_user_meta( $user_id, ‘membership_id’, $membership_id );
update_user_meta( $user_id, ‘membership_name’, $membership_name );
update_user_meta( $user_id, ‘membership_startdate’, $membership_startdate );
update_user_meta( $user_id, ‘membership_enddate’, $membership_enddate );
update_user_meta( $user_id, ‘member_since’, $member_since );}
add_action( ‘pmpro_after_change_membership_level’, ‘save_pmpro_level_to_meta’, 10, 2 );If you can shed some light on my problem, I would really appreciate it as ive been struggling with it for a while.
Thanks
- The topic ‘Timestamp issue when syncing to Hubspot’ is closed to new replies.