Last active
May 9, 2018 12:04
-
-
Save yasaryousuf/6431b63060cf5d6a3dba07bccafc1e2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'save_post', array($self, 'save_custom_fields'), 10, 3 ); | |
function save_custom_fields( $post_id, $post, $update) { | |
if ( $post->post_type != 'pfm_registration' ) { | |
return false; | |
} | |
if ( empty( $_POST['data'] ) ) { | |
return false; | |
} | |
update_post_meta( $post_id, 'pfm_registration_fields',$_POST['data'] ); | |
if ( !empty( $_POST['notification'] ) ) { | |
update_post_meta( $post_id, 'pfm_notification_fields',$_POST['notification'] ); | |
} | |
if ( !empty( $_POST['user_redirect'] ) ) { | |
update_post_meta( $post_id, 'pfm_user_redirect_fields',$_POST['user_redirect'] ); | |
} | |
$data = $_POST['data']; | |
$previous_metas = get_option('pfm_metadata'); | |
if (empty($previous_metas)) { | |
return false; | |
} | |
foreach($data as $arr) | |
{ | |
foreach($arr as $key => $val){ | |
if ($key == "metadata" && !empty($val) && !in_array($val, $previous_metas) ) { | |
$previous_metas[] = $val; | |
update_option( 'pfm_metadata', $previous_metas); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment