Skip to content

Commit 45dcf5c

Browse files
authored
Fix Getting and setting current user (#2)
1 parent e06984c commit 45dcf5c

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/.idea
12
/vendor/
2-
composer.lock
3+
composer.lock

src/Factories/Order.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ public function get_object_by_id( $object_id ) {
7979
}
8080

8181
private function api_call_setup() {
82-
$this->old_user = wp_get_current_user();
82+
$this->old_user = get_current_user_id();
8383

8484
// Setup the administrator user so we can actually retrieve the order.
8585
$user = new \WP_User( 1 );
86-
wp_set_current_user( $user );
86+
wp_set_current_user( $user->ID );
8787

8888
WC()->api->includes();
8989
WC()->api->register_resources( new WC_API_Server( '/' ) );

src/Factories/Product.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ public function get_object_by_id( $object_id ) {
7979
}
8080

8181
private function api_call_setup() {
82-
$this->old_user = wp_get_current_user();
82+
$this->old_user = get_current_user_id();
8383

8484
// Setup the administrator user so we can actually retrieve the order.
8585
$user = new \WP_User( 1 );
86-
wp_set_current_user( $user );
86+
wp_set_current_user( $user->ID );
8787
}
8888

8989

src/Factories/TaxRate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ public function get_object_by_id( $object_id ) {
8888
}
8989

9090
private function api_call_setup() {
91-
$this->old_user = wp_get_current_user();
91+
$this->old_user = get_current_user_id();
9292

9393
// Setup the administrator user so we can actually retrieve the order.
9494
$user = new \WP_User( 1 );
95-
wp_set_current_user( $user );
95+
wp_set_current_user( $user->ID );
9696
}
9797

9898

0 commit comments

Comments
 (0)