Hi,
I need to implement a custom server-side validation for a specific field (a phone verification token) during two scenarios:
User Registration (Create Profile)
Profile Edit (Update Profile)
I am currently using the voxel/frontend/after_post_validation hook to throw an exception if the validation fails. Here is a simplified version of my code:
add_action( ‘voxel/frontend/after_post_validation’, function( $ctx ) {
// Only apply to Profile post type
if ( $ctx[‘post_type’]->get_key() !== ‘profile’ ) {
return;
}
$custom_value = $ctx[‘values’][‘custom_field_id’] ?? null;
// My custom server-side check
$is_valid = my_custom_external_validation( $custom_value );
if ( ! $is_valid ) {
throw new \Exception( __( ‘Validation failed. Please check your data.’, ‘text-domain’ ) );
}
}, 10 );
– Is this the recommended hook to handle validation for both Registration and Profile Updates?
– Does throwing an \Exception within this hook safely prevent both the Post creation/update and the User registration in case of failure?
– Is there a better or more “native” Voxel way to perform an external API-based validation before data is committed to the database?
Thanks!
©2025 Created with 27collective LLC. All rights reserved