Using the HTML5 “required” attribute for a group of checkboxes?

When using the newer browsers that support HTML5 (FireFox 4 for example); and a form field has the attribute required=’required’; and the form field is empty/blank; and the submit button is clicked; the browsers detects that the “required” field is empty and does not submit the form; instead browser shows a hint asking the user … Read more

Check if username exist with AJAX

I’ve created a custom registration form for a WordPress MultiSite installation. It allows registrations of new blogs and users. I want to check with ajax if a given username is available. This is what I have so far: add_action( ‘wp_footer’, ‘pb_ajax_add_js’ ); function pb_ajax_add_js() { // add script to the footer wp_enqueue_script( ‘pb_ajax’, plugin_dir_url( __FILE__ … Read more

How to validate register settings array

I would like to know how to perform a proper validation with the register_setting() callback function. Here is a sample part of my code I want to work with: register_setting( ‘wpPart_options’, ‘wpPart_options’, array( &$this, ‘wpPartValidate_settings’ ) ); $this is an array of objects. And here is the content of my wpPartValidate_settings(); function. public function wpPartValidate_settings( … Read more

How to retain the values from dropdown category lists after wrong form submission?

I can’t figure out the the code for – How to retain the values from dropdown category lists after wrong form submission? Any suggesstions, thanx in advance. <select class=”selectpicker btn-block” name=”coupon_cat” id=”category” > <option selected value=””> Категори Сонгох</option> <?php $args[‘exclude’] = “12,20”; // omit these two categories $categories = get_categories($args); foreach($categories as $category) { ?> … Read more

Do I have to have a nonce for a custom comment field?

im working on my comment section and I have added a custom field <input type=”hidden” name=”be_user_star_rating” id=”be_user_star_rating” value=”” /> Its value is beign set by Javascript. Validating it with something like this: add_action( ‘comment_post’, ‘be_comment_rating_insert_comment’, 10, 1 ); function be_comment_rating_insert_comment( $comment_id ) { if( isset( $_POST[‘be_user_star_rating’] ) && $_POST[‘be_user_star_rating’] > 0 && $_POST[‘be_user_star_rating’] <= 5 … Read more