Check if username exist with AJAX

The problem is with your jQuery selector: var usr = $(“#site-addres-input”).attr(‘value’); Will get the default value of the input element. Typically this will be blank, because you’re not setting it ahead of time. You need to use: var usr = $(“#site-addres-input”).val(); I’m also noticing that you’re using #site-addres-input, but “address” has two s at the … Read more

How to validate register settings array

Personally I’d do it the same way, since it seems to be the only point where you can examine user input and validate it. Also, heavily borrowing from code sample in this excellent article: function wpPartValidate_settings( $input ) { if ( check_admin_referer( ‘wpPart_nonce_field’, ‘wpPart_nonce_verify_adm’ ) ) { // Create our array for storing the validated … Read more

How to load some jquery code to make validation in the theme customizer?

Create a /js subfolder in your theme directory, if such does not exist already. Save your script to a file in said folder. Then, in functions.php: if ( is_admin() ) { global $pagenow; if ( ‘customize.php’ === $pagenow ) { add_action( ‘admin_enqueue_scripts’, ‘wpse107236_enqueue_customizer_script’ ); } } function wpse107236_enqueue_customizer_script() { wp_enqueue_script( ‘your-script-handle’, get_template_directory_uri . ‘/js/your-script.js’, array( … Read more

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

Like Ash was saying, something like this using $_REQUEST or $_POST will do it. <?php $args[‘exclude’] = “12,20”; // omit these two categories $categories = get_categories($args); ?> <select class=”selectpicker btn-block” name=”coupon_cat” id=”category”> <option value=””>Категори Сонгох</option> <!– if nothing else is selected, this will be selected automatically –> <?php foreach($categories as $category): ?> <?php $selected = … Read more

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

A WordPress Nonce, while not a true nonce, functions similarly in that it exists to secure a form or page from unauthorized access and abuse. By default, the WordPress Comment Form only displays a nonce field if the current user has the unfiltered_html capability. So, if the form is implemented with standard procedures, all you … Read more

Persist fields with Setting API

This a really good question – my suggestion is to use transients. For instance, in your validation callback: wpse51669_validation_cb($settings){ //Perform validation checks if( $valid ){ //If settings validate return $validate_settings; } //Otherwise add settings error add_settings_error(‘my-plug-in-settings’,’error-with-xyz’, ‘I fell over’,’error’); //And add the failed settings to a transient set_transient( ‘my-plug-in-settings-invalid’, $settings, 60); return false; } Then … Read more

jQuery Validate wp_editor

Per the jQuery noConflict Wrappers section of the wp_enqueue_script() Codex page, the $ variable is not available in WordPress. You can replace $ with jQuery in your jQuery code, or do something like this: jQuery(document).ready(function($) { // your code here . . . });

Sanitizing and validating email field

According to the documentation, is_email() is used to validate an email and either returns the email if it is valid or false if it isn’t. So are using it correctly. The only thing I can see in your code is that if the email is not valid, you are settings the data to a boolean … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)