سؤال

How to write conditions on capabilities not on user role?

هل كانت مفيدة؟

المحلول

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.' ) );
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top