Aggiungere testo per utenti registrati ai post

Da AldoWiki.

È possibile in WordPress aggiungere, ai post pubblicati, del testo che solo gli utenti registrati possono leggere.

Nel file functions.php inserire queste righe:

add_shortcode( 'member', 'member_check_shortcode' );
 
function member_check_shortcode( $atts, $content = null ) {
	 if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
		return $content;
	return '';
}

Nel post basta inserire il testo tra i due shortcode [note] e [/note], ad esempio:

[member]
Questa è il testo che vedono solo gli utenti registrati.
[/member]

Fonte: WP Recipes.

Voci correlate

Strumenti personali
Namespace
Varianti
Azioni
Navigazione
Argomenti
ExtraWiki
Strumenti