Automattic\WooCommerce\Internal\StockNotifications\Frontend
FormHandlerService::handle_signup
Handle the form submit event.
Method of the class: FormHandlerService{}
No Hooks.
Returns
null. Nothing (null).
Usage
$FormHandlerService = new FormHandlerService(); $FormHandlerService->handle_signup();
FormHandlerService::handle_signup() FormHandlerService::handle signup code WC 10.3.6
public function handle_signup() {
// Sanity checks.
if ( ! Config::allows_signups() ) {
return;
}
if ( ! isset( $_POST['wc_bis_register'] ) ) { // phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
return;
}
try {
if ( self::requires_nonce_check() ) {
if ( ! isset( $_POST['wc_bis_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['wc_bis_nonce'] ), 'wc_bis_signup' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
wc_add_notice( $this->signup_service->get_error_message( SignupService::ERROR_INVALID_REQUEST ), 'error' );
return;
}
}
$data = $this->signup_service->parse( $_POST );
if ( \is_wp_error( $data ) ) {
wc_add_notice( $this->signup_service->get_error_message( $data->get_error_code() ), 'error' );
return;
}
$result = $this->signup_service->signup(
$data['product_id'],
$data['user_id'],
$data['user_email'],
$data['posted_attributes'] ?? array()
);
if ( \is_wp_error( $result ) ) {
wc_add_notice( $this->signup_service->get_error_message( $result->get_error_code() ), 'error' );
return;
}
wc_add_notice( $this->signup_service->get_signup_user_message( $result->get_code(), $result->get_notification() ), 'success' );
} catch ( \Throwable $e ) {
wc_add_notice( $this->signup_service->get_error_message( SignupService::ERROR_FAILED ), 'error' );
$this->logger->error( $e->getMessage(), array( 'source' => 'stock-notifications-signup-errors' ) );
return;
}
}