WordPress.org

Ready to get started?Download WordPress

Forums

Show alternate content for guests.... (5 posts)

  1. el terrible bmw
    Member
    Posted 5 years ago #

    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! :)

  2. el terrible bmw
    Member
    Posted 5 years ago #

    BUMP anyone?

  3. webjunk
    Member
    Posted 5 years ago #

    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.

  4. el terrible bmw
    Member
    Posted 5 years ago #

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

  5. ApnaySMS
    Member
    Posted 5 years ago #

    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 ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.