Created
July 8, 2017 15:42
-
-
Save PCianes/881b3ceb97db114880df3a58a8d1026d to your computer and use it in GitHub Desktop.
Add capability to user or role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Example 1 | |
function add_cap_upload_files_to_user_id() { | |
$user = new WP_User( $user_id ); | |
$user->add_cap( 'upload_files' ); | |
} | |
add_action( 'admin_init', 'add_cap_upload_files_to_user_id'); | |
// Example 2 | |
function allow_contrib_upload() { | |
$contrib = get_role( 'contributor' ); | |
$contrib->add_cap( 'upload_files' ); | |
} | |
add_action( 'admin_init', 'allow_contrib_upload', 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment