函数文档

user_can_delete_post_comments()

💡 云策文档标注

概述

user_can_delete_post_comments() 是一个已弃用的 WordPress 函数,用于检查指定用户是否有权限删除特定文章的评论。自版本 2.0.0 起,建议使用 current_user_can() 替代。

关键要点

  • 函数已弃用:自 WordPress 2.0.0 起,此函数被标记为弃用,应改用 current_user_can() 进行权限检查。
  • 功能逻辑:当前实现基于用户是否能编辑文章评论来判断删除权限,即调用 user_can_edit_post_comments()。
  • 参数说明:接受 $user_id(必需)、$post_id(必需)和 $blog_id(可选,默认值为 1,但当前未使用)。
  • 返回值:返回布尔值,true 表示用户有权限删除指定文章的评论。

注意事项

使用此函数会触发 _deprecated_function() 警告,建议开发者更新代码以避免兼容性问题。


📄 原文内容

Whether user can delete a post.

Description

See also

Parameters

$user_idintrequired
$post_idintrequired
$blog_idintoptional
Not Used

Default:1

Return

bool returns true if $user_id can delete $post_id’s comments

Source

function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
	_deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' );

	// Right now if one can edit comments, one can delete comments.
	return user_can_edit_post_comments($user_id, $post_id, $blog_id);
}

Changelog

Version Description
2.0.0 Deprecated. Use current_user_can()
1.5.0 Introduced.