Hook before user is created and make some custom validation

You need to add , 10, 3 after your closure to set the hook priority and (more importantly) the number of accepted arguments – otherwise $user_email and $errors will not be passed. add_action( ‘register_post’, function ( $user_login, $user_email, $errors ) { $userIsValid = ValidateUser::make($errors); if(!$userIsValid) { $errors->add( ‘bad_email_domain’, ‘<strong>ERROR</strong>: errors’ ); } }, 10, 3 … Read more

Add action save post when create and publish

I think one key question here is how _select_match_from_id meta value is saved? Is it some metafield on the post edit screen or from some other logic? If I may assume that it is from a metafield, then you could just read its value from the $_POST array. You could also improve your code by … Read more

Hook a script as the very last one before the closing body tag

Assuming these are scripts enqueued via wp_enqueue_script(), the absolute best solution would be to locate the registration/enqueuement of the script creating the element and simply specify it’s handle as a dependency for your script. WordPress will then ensure that yours loads after that dependency. There are other work-arounds to ensure that your script is the … Read more