admin管理员组文章数量:1425051
Here's my problem. I need following solution.
If a user is in the admin area of Wordpress and is not an administrator - and creates a page or product(via WooCommerce) - that if this user clicks on the blue "publish" button, the page/product should goes into the status "Pending Review", no matter what is selected in the status option or if it is already a published page/post/product whatever. If the blue published button gets clicked, by a non-admin, it always should go to pending review status.
I already fixed the problem with Javascript, but well the User could simply manipulate it - So I am searching for a PHP function.
Here is my current script made with Vanilla JS
add_action( 'init', 'savePendingReview' );
function savePendingReview() {
if(is_admin()) {
global $pagenow;
if(!current_user_can('administrator') && 'post.php' === $pagenow) {
echo '<script>
window.addEventListener("load", function() {
document.getElementById("post_status").selectedIndex = "1";
</script>';
}
}
}
As you see my Javascript solution is pretty dirty. Any ideas how I can fix the problem with PHP? I need to hook into the save_post action to change the post_status.
本文标签: functionsIf click on SavePublish change Post Status to Pending Review instead Publish
版权声明:本文标题:functions - If click on SavePublish change Post Status to Pending Review instead Publish 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745438795a2658350.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论