Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 代码无法从WordPress前端删除帖子_Php_Wordpress - Fatal编程技术网

Php 代码无法从WordPress前端删除帖子

Php 代码无法从WordPress前端删除帖子,php,wordpress,Php,Wordpress,我试图允许我的用户删除他们从前端创建的帖子 我知道他们必须有删除帖子的用户能力。他们被指派具有此功能的“作者”角色 然后我添加了代码,该代码仅在 1) 这篇文章的作者或作者 2) 拥有编辑其他帖子的权限 现在,链接出现了。。。他们可以点击它。。。它要求他们确认是否要删除。。。。它只会将它们发送回主页。它实际上并没有删除。以下是该网站的URL: <?php if (($post->post_author == $current_user->ID) || (current

我试图允许我的用户删除他们从前端创建的帖子

我知道他们必须有删除帖子的用户能力。他们被指派具有此功能的“作者”角色

然后我添加了代码,该代码仅在

1) 这篇文章的作者或作者

2) 拥有编辑其他帖子的权限

现在,链接出现了。。。他们可以点击它。。。它要求他们确认是否要删除。。。。它只会将它们发送回主页。它实际上并没有删除。以下是该网站的URL:


<?php 

if (($post->post_author == $current_user->ID) || (current_user_can('edit_others_pages'))) { ?>
    <a onclick="return confirm('Are you SURE you want to delete this post?')" href="<?php echo get_delete_post_link( $post->ID ) ?>">delete</a>

    <?php do_action( 'gform_update_post/edit_link', array(
           'post_id' => $post->ID,
           'url' => $custom_post_edit_url
            ) ); ?>
    <?php do_shortcode('[gform_update_post_edit_link]'); ?>

<?php } ?>