am使用此功能从前面删除帖子
// Delete from Front-End Link
function wp_delete_post_link($link = \'Delete This\', $before = \'\', $after = \'\', $title="Move this item to the Trash", $cssClass="delete-post") {
global $post;
if ( $post->post_type == \'page\' ) {
if ( !current_user_can( \'edit_page\' ) )
return;
} else {
if ( !current_user_can( \'edit_post\' ) )
return;
}
$delLink = wp_nonce_url( site_url() . "/wp-admin/post.php?action=trash&post=" . $post->ID, \'trash-\' . $post->post_type . \'_\' . $post->ID);
$link = \'<a class="\' . $cssClass . \'" href="\' . $delLink . \'" onclick="javascript:if(!confirm(\\\'Are you sure you want to move this item to trash?\\\')) return false;" title="\'.$title.\'" />\'.$link."</a>";
return $before . $link . $after;
}
其工作效率为100%,但我使用此功能限制任何管理员访问wp admin,使用此功能:function restrict_admin(){
//if not administrator, kill WordPress execution and provide a message
if ( ! current_user_can( \'create_users\' ) ) {
wp_die( __(\'You are not allowed to access this part of the site\') );
}
}
add_action( \'admin_init\', \'restrict_admin\', 1 );
my problem , 如何允许用户(非管理员)删除自己的帖子?