Wp-admin登录后检查GET_POST值

时间:2017-08-22 作者:jack

我想在登录到wp admin后检查get\\u选项值。

我已将日期保存在get\\u选项中。我想检查get\\u选项中的值是否与wp admin登录后的当前日期相同。

如果相同,那么我想显示管理员通知。

每次我登录到wp admin时,它都会检查get\\u选项值。

这是我的管理员通知代码。I have no idea how can i check the get_option value after wp-admin login.

function sample_admin_notice__success() {
            ?>
     <div class="notice notice-success is-dismissible">
     <p><?php _e( \'Done!\', \'sample-text-domain\' ); ?></p>
      </div>
     <?php
   }
   add_action( \'admin_notices\', \'sample_admin_notice__success\' );
任何帮助都将不胜感激。

1 个回复
最合适的回答,由SO网友:Jacob Peattie 整理而成

您只需在通知周围使用一个普通的if语句,这样它只在选项的值与当前日期匹配时出现。

function wpse_277689_admin_notice() {
    if ( get_option( \'expiry_date\' ) === date( \'d/m/Y\') ) :
        ?>

        <div class="notice notice-success is-dismissible">
            <p><?php _e( \'Done!\', \'sample-text-domain\' ); ?></p>
        </div>

        <?php
    endif;
}
add_action( \'admin_notices\', \'wpse_277689_admin_notice\' );

结束

相关推荐

Wp-admin删除部分url

This looks like wp-admin remove the subfolder URL but it\'s not the same problem, because the subfolder part is not a subfolder.I\'m working on a clean VM as a host for Docker containers. I have a dockerized Wordpress listening on 8080 on the VM.I can hit