How to write conditions based on user capabilities not on user role?
-
20-05-2021 - |
Domanda
How to write conditions on capabilities not on user role?
Soluzione
With current_user_can(), or $user->has_cap() for other users:.
if ( ! current_user_can( 'delete_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange