Skip to content

Instantly share code, notes, and snippets.

@osvik
Last active June 22, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osvik/9fcb4eb465743438782afb78d7804900 to your computer and use it in GitHub Desktop.
Save osvik/9fcb4eb465743438782afb78d7804900 to your computer and use it in GitHub Desktop.
<?php
/**
* Añade capacidades a editores y admins
*/
function editor_unfiltered_upload( $caps, $cap, $user_id ) {
if ( "unfiltered_upload" === $cap && user_can( $user_id, "editor" ) ) {
$caps = array( "unfiltered_upload" );
}
return $caps;
}
add_filter( "map_meta_cap", "editor_unfiltered_upload", 1, 3 );
function admin_unfiltered_upload( $caps, $cap, $user_id ) {
if ( "unfiltered_upload" === $cap && user_can( $user_id, "administrator" ) ) {
$caps = array( "unfiltered_upload" );
}
return $caps;
}
add_filter( "map_meta_cap", "admin_unfiltered_upload", 1, 3 );
function editor_unfiltered_html( $caps, $cap, $user_id ) {
if ( "unfiltered_html" === $cap && user_can( $user_id, "editor" ) ) {
$caps = array( "unfiltered_html" );
}
return $caps;
}
add_filter( "map_meta_cap", "editor_unfiltered_html", 1, 3 );
function admin_unfiltered_html( $caps, $cap, $user_id ) {
if ( "unfiltered_html" === $cap && user_can( $user_id, "administrator" ) ) {
$caps = array( "unfiltered_html" );
}
return $caps;
}
add_filter( "map_meta_cap", "admin_unfiltered_html", 1, 3 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment