Get updated value after post update (custom post t

2019-06-01 17:22发布

I want to get lasted updated value on post update action, I have used "save_post" , post_updated publish_post hook but all return old value but I need current updated value at same time:

I have tried below code:

add_action( 'post_updated', 'wpse63478_save' );
function wpse63478_save($post_id) {
   $agent_property_developer = get_post_meta($post_id , 'agent_property_developer' , true);
  $user_id = get_post_meta($post_id , 'agent_user' , true);

  if($agent_property_developer == 1) {
       update_user_meta($user_id , 'property_developer' , 1);
    }
   else {
              update_user_meta($user_id , 'property_developer' , 0);
    }

}

In above code I want to update usemeta based on current post meta value. But it return old value.

Eg: $agent_property_developer == 1 and I'll change it to 0 but it return 1 and if 1 and then return 0.

Any help will be appreciated.

标签: php wordpress
0条回答
登录 后发表回答