Skip to content

Instantly share code, notes, and snippets.

@New0
Created June 30, 2020 10:30
Show Gist options
  • Save New0/2cdf112073036ee988cb3d4d5d4f38b9 to your computer and use it in GitHub Desktop.
Save New0/2cdf112073036ee988cb3d4d5d4f38b9 to your computer and use it in GitHub Desktop.
Caldera Forms using Custom fields add-on, save the new Post ID as User meta data.
<?php
/** Hook in when custom fields are saved by CF Custom fields to write entry ID as user meta */
add_action( 'cf_custom_fields_post_save_meta_key_to_post_type', function($value, $slug, $post_id, $field, $form){
if( $slug === "meta_post_id" ){
if( $value === $post_id){
return;
} else {
update_user_meta( get_current_user_id(), "meta_post_id", $post_id );
}
}
}, 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment