Support

Account

Home Forums Backend Issues (wp-admin) Update post owner based on custom field change Reply To: Update post owner based on custom field change

  • Guess i solved it with the following code:

    function action_function_name( $field ) {
    	global $post;
        $id = $post->ID;
    	$value = get_field('owner',$id);
    	$args = array(
          'ID' => $id,
          'post_author' => $value,
    	);
    	wp_update_post( $args );
      return $field;
    }
    add_action( 'acf/render_field/name=owner', 'action_function_name', 10, 1 );