Wordpress: displaying an error message - hook admin_notices fails on wp_insert_post_data or publish_post

前端 未结 3 460
长发绾君心
长发绾君心 2021-01-18 09:11

I\'m adding validation so if a post is in a particular category, it needs certain Custom Fields to be set.

This should be easy hooking wp_insert_post_data

3条回答
  •  庸人自扰
    2021-01-18 09:47

    if($out = $_SESSION['admin_notices']) { 
          $_SESSION["admin_notices"] = ""; 
          echo $out; 
    }
    

    This condition is always TRUE so it always reset your $_SESSION['admin_notices'] var

提交回复
热议问题