I found somewhere in the web simple code to make own shortcode. There was ob_start(). Now I know that I needn’t do_start() but when after delete this element funstion still not show my links. What am I doing wrong?
I found one error. My page with shorecode is download not login.
function ShowPrivateFile() {
$output='';
$allowed_roles = array('subskrybent2', 'subskrybent3', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) ) {
$output = 'Pliki dostępne tylko po zalogowaniu:'.'<a href="https:">Protokół_z_zebrania_2015_11_15.doc</a></br>'.
'<a href="https:">KARTA_INDYWIDUALNEGO_GŁOSOWANIA.doc</a></br>'.
'<a href="https">Faktura Klamki.JPG</a></br>'.
'<a href="https">Faktura Wkladki Klucze.JPG</a></br>';
}
return $output;
}
add_shortcode("pokaz_prywatne_pliki", "ShowPrivateFile");
Still not working..
I foreget
$user = wp_get_current_user();
now is working
maybe for someone it’s helpful
regards
yes,
u need paste this: $user = wp_get_current_user();
below output or func declaration and before code:
$allowed_roles = array('subskrybent2', 'subskrybent3', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) )
like this:
function ShowPrivateFile() {
$output='';
$user = wp_get_current_user();
$allowed_roles = array('subskrybent2', 'subskrybent3', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) ) {
$output = 'Pliki dostępne tylko po zalogowaniu:'.'<a href="https:">Protokół_z_zebrania_2015_11_15.doc</a></br>'.
'<a href="https:">KARTA_INDYWIDUALNEGO_GŁOSOWANIA.doc</a></br>'.
'<a href="https">Faktura Klamki.JPG</a></br>'.
'<a href="https">Faktura Wkladki Klucze.JPG</a></br>';
}
return $output;
}
add_shortcode("pokaz_prywatne_pliki", "ShowPrivateFile");
it should be work. Sorry but i not every day on computer now. I hope that help u
best regard
when i use ob_start(); i always finish with return ob_get_clean();