Last active
September 4, 2017 18:33
-
-
Save perezdans/2429378cdc53f9a25b3eaa5820b928ca to your computer and use it in GitHub Desktop.
Código para introducir en el functions.php para crear un shortcode que permita que determinados contenidos solo se muestren a determinados usuarios
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 | |
add_shortcode( ‘registrado’, ‘shortcode_para_registrados’ ); | |
function shortcode_para_registrados( $atts, $content = null ) { | |
global $current_user; | |
get_currentuserinfo(); | |
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) { | |
if (is_array($atts) && $atts['usuario'] == $current_user->user_login) | |
return $content; | |
} | |
return ''; | |
} | |
/* | |
Ejemplo: | |
[registrado usuario="alvarez"] Esto solo le sale a alvarez [/registrado] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment