Date modified is read only and set by WP after update

This commit is contained in:
Mike Jolley 2016-08-16 11:57:25 +01:00
parent 46b6ca0f3b
commit e99798f16e
2 changed files with 2 additions and 7 deletions

View File

@ -991,10 +991,10 @@ class WC_Customer extends WC_Legacy_Customer {
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
$this->set_date_modified( time() );
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
$wp_user = new WP_User( $this->get_id() );
$this->set_date_created( strtotime( $wp_user->user_registered ) );
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
$this->read_meta_data();
}
}
@ -1074,11 +1074,10 @@ class WC_Customer extends WC_Legacy_Customer {
update_user_meta( $this->get_id(), 'shipping_state', $this->get_shipping_state() );
update_user_meta( $this->get_id(), 'shipping_country', $this->get_shipping_country() );
update_user_meta( $this->get_id(), 'paying_customer', $this->get_is_paying_customer() );
$this->set_date_modified( time() );
update_user_meta( $this->get_id(), 'last_update', $this->get_date_modified() );
update_user_meta( $this->get_id(), 'first_name', $this->get_first_name() );
update_user_meta( $this->get_id(), 'last_name', $this->get_last_name() );
wp_update_user( array( 'ID' => $this->get_id(), 'role' => $this->get_role() ) );
$this->set_date_modified( get_user_meta( $this->get_id(), 'last_update', true ) );
$this->save_meta_data();
}

View File

@ -80,10 +80,6 @@ class WC_Tests_CustomerCRUD extends WC_Unit_Test_Case {
$customer_id = $customer->get_id();
$this->assertNotEquals( 0, $customer->get_id() );
$customer->delete();
$user_object = get_user_by( 'id', $customer_id );
$this->assertFalse( $user_object );
$customer->read( $customer_id );
$this->assertEquals( 0, $customer->get_id() );
}