How to make first_name and last_name required fields in user profile?

You could check the $_POST variable when updating the user profile page. I would hook into user_profile_update_errors and do something along those lines. This filter will not save to DB if errors are found. add_filter(‘user_profile_update_errors’, ‘wpse_236014_check_fields’, 10, 3); function wpse_236014_check_fields($errors, $update, $user) { // Use the $_POST variable to check required fields if( empty($_POST[‘first_name’]) ) … Read more

Problem with is_active_sidebar?

Please try this one,because without id we i don’t think that will work: function reg_l_sid() { $args = array( ‘id’ => ‘sidebar-footer-6’,’name’=> ‘Left-sidebar’); register_sidebar($args); } add_action(‘widgets_init’, ‘reg_l_sid’); and inside template: if (is_active_sidebar(‘sidebar-footer-6’)) { dynamic_sidebar(‘sidebar-footer-6’); } else { echo ‘Please add widgets’; }

Custom Post Type | Fatal Error on register_post_type()

try these changes: 1) To use add_action() when your plugin or theme is built using classes instead of passing just the function name, you need to pass an array with a reference to the class ($this) and the callable function (‘custom_post_type’) function __construct() { add_action(‘init’, array( $this, ‘custom_post_type’ ) ); } 2) The original ‘activate’ … Read more

How to run an add_action hook for specific page

Put is_page() inside the callback function: function include_regForm_validation() { wp_register_script( ‘jQuery_form_validation’, ‘https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js’,array(‘jquery’), ‘1.0’, true ); if ( is_page( ‘login’ ) ) { wp_enqueue_script( ‘jQuery_form_validation’); } } add_action( ‘wp_enqueue_scripts’, ‘include_regForm_validation’ ); WordPress has not determined what page/archive has been requested yet when hooks are added with add_action(), so you need to make the determination only when … Read more

Ensure function has completed before allowing another Ajax call

I usually use CSS classes to control AJAX requests affecting a specific element. This way you can prevent unwanted AJAX requests on that element, while other AJAX requests may still be triggered, being bound to other elements. $(‘.slot’).on(‘click’, ‘a.book’, function(e) { e.preventDefault(); // Check if doing ajax if($(this).hasClass(“doing-ajax”)) return false; $(this).addClass(“doing-ajax”); var user = $(‘#rjb_day’).attr( … Read more