user_row_actions
云策文档标注
概述
user_row_actions 是一个 WordPress 过滤器钩子,用于修改用户列表表中每个用户下方显示的操作链接。它允许开发者自定义或移除默认的编辑、删除等操作。
关键要点
- 过滤器钩子名称为 user_row_actions,用于过滤用户列表中的操作链接数组。
- 参数包括 $actions(操作链接数组)和 $user_object(当前用户的 WP_User 对象)。
- 默认操作链接在单站点中为 'Edit' 和 'Delete',在多站点中为 'Edit' 和 'Remove'。
- 此钩子自 WordPress 2.8.0 版本引入,常用于 WP_Users_List_Table::single_row() 方法中。
代码示例
function wpdocs_user_row_actions( $actions ) {
if ( isset( $actions['view'] ) ) {
unset( $actions['view'] );
}
return $actions;
}
add_filter( 'user_row_actions', 'wpdocs_user_row_actions' );注意事项
此钩子也可与 ms_user_row_actions 配合使用,适用于多站点环境。示例代码展示了如何移除 'view' 链接,开发者可根据需要添加或修改其他操作。
原文内容
Filters the action links displayed under each user in the Users list table.
Parameters
Source
$actions = apply_filters( 'user_row_actions', $actions, $user_object );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
Skip to note 2 content
Erik
This snippet removes the link to the author archive. Can be used with
ms_user_row_actionsaswell.function wpdocs_user_row_actions( $actions ) { if ( isset( $actions['view'] ) ) { unset( $actions['view'] ); } return $actions; } add_filter( 'user_row_actions', 'wpdocs_user_row_actions' );