• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Members only shortcode

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Members only shortcode

This topic is: not resolved

Tagged: members only, php

  • This topic has 3 replies, 2 voices, and was last updated 11 years, 4 months ago by tornado.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 28, 2014 at 2:29 pm #133158
    tornado
    Participant

    Hi folks!

    If I use the following code to ensure that text wrapped in the [members_only] shortcode is visible only to members, how would I add a link to text the code generates:

    I want to change the 'To view this content please login' to 'To view this content register here', which would link to my custom registration page.

    add_shortcode( 'members_only', 'members_only_shortcode' );
    function members_only_shortcode( $atts, $content = null ) 
    {
        if ( is_user_logged_in() && !empty( $content ) && !is_feed() )
        {
            return $content;
        }

    return 'To view this content please login.';
    }

    Any help would be awesome.

    G

    November 28, 2014 at 7:03 pm #133169
    Brad Dalton
    Participant

    Link to the source of the code please.


    Tutorials for StudioPress Themes.

    November 28, 2014 at 7:29 pm #133170
    Brad Dalton
    Participant

    Something like this is probably what you want http://wpsites.net/wordpress-admin/members-shortcode-to-hide-content-from-logged-out-users/


    Tutorials for StudioPress Themes.

    November 29, 2014 at 6:50 am #133200
    tornado
    Participant

    Thanks, Brad. That's spot on. Really good site.

    Cheers.

    G

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble