당신은 일시적 변수 또는 유사한 전략을 수립해야 할 것이다 감지 코드입니다
function my_error_notice() {
if (!current_user_can('editor')) {
?>
<div class="error notice">
<p><?php _e('Sorry only the Administrators are allowed to create new tags, please select from the prepopulated suggestions or contact an Administrator for more assistence.', 'my_plugin_textdomain'); ?></p>
</div>
<?php
}
add_action('admin_notices', 'my_error_notice');
오류를 보여줍니다 내 코드입니다 WP 때문에 게시물을 저장 한 후 리디렉션합니다.
다음은 기본적인 아이디어입니다. 응용 프로그램에서 작동하도록 조정하는 것은 사용자의 몫입니다.
function my_error_notice() {
$show_notice = get_transient('show_post_tag_notice');
if (! $show_notice) {
return;
}
delete_transient('show_post_tag_notice');
if (!current_user_can('editor')) { ?>
<div class="error notice">
<p><?php _e('Sorry only the Administrators are allowed to create new tags, please select from the prepopulated suggestions or contact an Administrator for more assistence.', 'my_plugin_textdomain'); ?></p>
</div>
<?php
}
}
add_action('admin_notices', 'my_error_notice');
add_action('create_term','undo_create_term',10, 3);
function undo_create_term ($term_id, $tt_id, $taxonomy) {
if (!current_user_can('editor')) {
if($taxonomy == 'post_tag') {
wp_delete_term($term_id,$taxonomy);
set_transient('show_post_tag_notice', true);
}
}
}
예! 그래서 현재 오류가 지속적으로 보여, 나는 사용자가 게시물에 새 태그를 추가하려고 할 때만 표시해야합니다. –
코드의 해당 부분을 포함하도록 위의 내용을 편집했습니다 –