api_client_creds = $api_client_creds; } /** * Set the user_id and email, make the API call, and handle the response. * * @param string|null $user_id - Auth0 user ID to change the email for. * @param string|null $email - New email. * * @return bool|string */ public function call( $user_id = null, $email = null ) { if ( empty( $user_id ) || empty( $email ) ) { return self::RETURN_ON_FAILURE; } if ( ! $this->set_bearer( self::API_SCOPE ) ) { return self::RETURN_ON_FAILURE; } return $this ->set_path( 'api/v2/users/' . rawurlencode( $user_id ) ) ->add_body( 'email', $email ) // Email is either changed by an admin or verified by WP. ->add_body( 'email_verified', true ) ->add_body( 'client_id', $this->options->get( 'client_id' ) ) ->patch() ->handle_response( __METHOD__ ); } /** * Handle API response. * * @param string $method - Method that called the API. * * @return integer */ protected function handle_response( $method ) { if ( $this->handle_wp_error( $method ) ) { return self::RETURN_ON_FAILURE; } if ( $this->handle_failed_response( $method ) ) { return self::RETURN_ON_FAILURE; } return true; } }