custom message on quick edit
-
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(){ var_dump($_SESSION['my_admin_notices']); if(isset($_SESSION['my_admin_notices'])) { print $_SESSION['my_admin_notices']; } else { $value = ''; } unset($_SESSION['my_admin_notices']); } 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)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘custom message on quick edit’ is closed to new replies.