get_editable_roles

函式
get_editable_roles ( No parameters )
返回值
  • (array[]) Array of arrays containing role information.
定義位置
相關方法
get_editable_authorsget_editable_user_idsget_the_title_rssget_edit_profile_urlget_site_url
引入
2.8.0
棄用
-

get_editable_roles: 這個函式用來檢索可以被當前使用者編輯的使用者角色列表。這可以用來定製網站的使用者管理功能的行為。

獲取當前使用者允許編輯的過濾後的使用者角色列表。

簡單的函式,其主要目的是允許過濾$wp_roles物件中的角色列表,這樣外掛就可以根據情況或使用者的編輯情況刪除不合適的角色。特別是在沒有過濾的情況下,任何有edit_users許可權的人都可以把別人編輯成管理員,即使他們只是編輯或作者。這個過濾器允許管理員委託使用者管理。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_editable_roles() {
$all_roles = wp_roles()->roles;
/**
* Filters the list of editable roles.
*
* @since 2.8.0
*
* @param array[] $all_roles Array of arrays containing role information.
*/
$editable_roles = apply_filters( 'editable_roles', $all_roles );
return $editable_roles;
}
function get_editable_roles() { $all_roles = wp_roles()->roles; /** * Filters the list of editable roles. * * @since 2.8.0 * * @param array[] $all_roles Array of arrays containing role information. */ $editable_roles = apply_filters( 'editable_roles', $all_roles ); return $editable_roles; }
function get_editable_roles() {
	$all_roles = wp_roles()->roles;

	/**
	 * Filters the list of editable roles.
	 *
	 * @since 2.8.0
	 *
	 * @param array[] $all_roles Array of arrays containing role information.
	 */
	$editable_roles = apply_filters( 'editable_roles', $all_roles );

	return $editable_roles;
}

常見問題

FAQs
檢視更多 >