Support » Plugins » Hacks » custom message on quick edit

  • Resolved yerlix


    On my site, I check if an array doesn’t exceed 3 values. Now I want to doe this as well on the quick edit form.

    So far, I get the message only when I refresh the browser.

    The code I use when I save the quick edit:

    if ( array_key_exists( 'speciality', $_POST ) ){
    			    // update_post_meta( $post_id, 'med-spec', $_POST[ 'speciality' ] );
    			    // inlezen specialiteiten
    		        $specs = preg_split("/[\s,]+/", $_POST['speciality']);
    		        // check of er maximum 3 ingevuld zijn
    		        if (count($specs) < 4){
    		            update_post_meta( $post_id, 'med-spec', $_POST[ 'speciality' ] );
    		        } else {
    		            $_SESSION['my_admin_notices'] = "<div class='error'><p>Maximum 3 specialiteiten!</p></div>";
    		            return false;

    The code above checks if the array is maximum 3 values long and puts a message in the session when it is not.

    On my page I recall the session:

    function my_admin_notices(){
            if(isset($_SESSION['my_admin_notices'])) {
                print  $_SESSION['my_admin_notices'];
            } else {
               $value = '';
        add_action( 'admin_notices', 'my_admin_notices' );

    But this shows the message only on refreshing the browser.

    Is there a hook for this? Or must this be done through javascript?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    I looked into leveraging the bulk message facility, but since the messages only display at the top of the page, which may be off screen, it’s a very poor approach. Looks like javascript is your best option.

    Thanks for your input.

    My bulk edit does work now, only the quick edit doesn’t. Currently I’m trying to reload the page with javascript, but this gives me an ugly interface for a couple seconds.

    Is there a way to call the error box with javascript?

    Moderator bcworkz


    You can get the error box via an AJAX request, but you may be better off with a pure javascript or jQuery error check which would not involve HTTP traffic at all. Perhaps by hooking into the field’s onblur event?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom message on quick edit’ is closed to new replies.