WordPress.org

Support

Support » How-To and Troubleshooting » Show alternate content for guests….

Show alternate content for guests….

  • I basically want to have 2 images. One that links to download url, and another that links to registration page. I want the first the show for logged in users, and the other for guests. How do I do this? I’ve seen php code that does this, but I don’t want to use php in posts with that hack, I was wondering if that’s a plugin or default WP tag like.

    [registered]show for registered users[/register]
    [guests]please register – show for guests[/guests]

    Something like that?

    Thanks in advance! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • BUMP anyone?

    Don’t know anyway without using php code. You would need code to do the validation. There are membership plugins that sort of can do that but don’t think that is what you need.

    Hmm I guess I could use that plugin that allows use of php in posts. Thoughts?

    paste this in functions.php file:

    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 '';
    }

    Once done, you can add the following to your posts to create a portion or text (or any other content) that will be only displayed to registered users:

    [member]
    This text will be only displayed to registered users.
    [/member]

    have a nice day 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show alternate content for guests….’ is closed to new replies.