Visualizzazione 4 filoni di risposte
Visualizzazione 4 filoni di risposte
- Devi essere connesso per rispondere a questo topic.
Email: info@wpitaly.it
Home › Forum › Problemi Vari con WP › pagine private menu wp 3.0
Ciao a tutti, ho una domanda, c’è un modo per nascondere un link di un menu creato con wordpress agli utenti non registrati?o ancora meglio renderlo visibile solo all’amministratore?
In pratica vorrei nascondere il link personalizzato che mi manda nel pannello di amministrazione del sito.
kikko088
semoplice, basta rendere la pagina privata. solo quando si è loggati si ha accesso cercandola nell’url o seguindo un link inserito in qualche post o widget.
al contrario se sei sloggato (caso utenti) non si può accedere a quella pagina.
utilizzando il plugin page2link puoi inserire il “tuo link” nella pagina stessa e verrai reindirizzato
con questo codice puoi creare uno shortcode da inserire in qualsiasi post per inserire testo visibile solo all’admin, con qualche modifica puoi utilizzarlo dove vuoi:
function admin_note( $attrs, $content = null ) {
if ( current_user_can( 'publish_posts' ) )
return '<div class="admin-note">' . $content . '</div>';
return '';
}
add_shortcode( 'admin-note', 'admin_note' );
[note]Questa nota è visibile solo agli amministratori del blog[/note]
Cosଠte l’ho semplificata:
<?php if ( current_user_can( 'publish_posts' ) )
echo 'Pippo Bello';
?>
per garantirsi che solo un utente di livello admin e non altri livelli (es redattori)vedano quel blocco meglio usare una capacità più restrittiva es current_user_can( ‘delete_plugins’ ) anche current_user_can( ‘administrator’ ) visto che la funzione accetta capacità o ruoli…
WPItaly - Copyright Creative Commons: CC BY-NC-SA 4.0