Filter and validate user role in registration
You can use wp_dropdown_roles()
You can use wp_dropdown_roles()
If you look at the validator output, you will see there is a little red arrow pointing to the space between “knows” and “me”. Copy “knows me” to a simple text editor like Notepad and you will see that the blank space consists of two characters, a space and an unknown invisible one. To get … Read more
You can create a custom ajax action or add a custom parameter to your post request and catch it on init action callback. In that ajax action/init callback you can use wp_signon function to check if the credentials are ok and return proper response. I would write some code but I’m on mobile and would … Read more
I have been able to check the file size with $ _FILES [$ id] [ ‘size’] > 0. So the WP_error validation will only run if there is a file in bytes.
You’ll want to checkout the registration_errors filter. Make sure the role is being posted within the particular registration form. Instead of conditionally adding your action you have to check within the filter if role and email are valid. add_action( ‘registration_errors’, ‘wpse_248123_registration_errors’ ); function wpse_248123_registration_errors( $sanitized_user_login, $user_email, $errors ) { if ( empty( $_POST[‘role’] ) ) … Read more
There is the option that you don’t allow the user to register on the main site, allowing them to register on the subsite only. The plugin network-subsite-user-registration allows this, if the user is already registered on the network then they are automatically added, by the plugin, to the site requesting registration. The hook that does … Read more
This is how I got AJAX working for me. I digested this tutorial. https://codex.wordpress.org/AJAX_in_Plugins I created an external JS file and enqueued after jQuery because of its dependency on jQuery. I created a PHP function to respond to the AJAX call by echoing what was sent. When that worked, I made the PHP function send … Read more
Validating Error with submit button
Form Sanitization and Validation
First check that it’s not empty, then typecast to a string value as a security precaution, because it’s always possible for this to be submitted as an array; e.g., by an attacker. Then unslash, sanitize, and continue by checking length and anything else that you’d like to validate. if ( ! empty( $_POST[‘contact_msg’] ) ){ … Read more