0
我用這將導致以下print_r的輸出與所有可用的用戶角色:只列出自定義用戶角色(濾波器陣列)
Array (
[administrator] => Administrator
[editor] => Editor
[author] => Author
[contributor] => Contributor
[subscriber] => Subscriber
[customer] => Customer
[shop_manager] => Shop Manager
[custom_role_test1] => Custom Role Test 1
[custom_role_test2] => Custom Role Test 2
)
我已經定義了一個第二陣列內置的來自WordPress和角色WooCommerce:
$built_in_roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber',
'shop_manager', 'customer');
是否有一個PHP函數可用來去除從$available_roles
陣列$built_in_roles
?
使我得到了以下的print_r輸出數組:
Array (
[custom_role_test1] => Custom Role Test 1
[custom_role_test2] => Custom Role Test 2
)