• Hello,
    I am using the ithemes php method to restrict content in my custom template. All works well, however I am not seeing the “Restricted Content Message” for visitors that are not logged in. Instead, the restricted content is hidden without message.

    Here is the code we are using:

    <?php if ( rcp_user_has_paid_membership() ) : ?>
    	<p>Content inside here would only be visible to active paid and active free subscribers.</p>
    <?php endif; ?>

    Any ideas? Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You could use else. For example, something like this:

    <?php if ( rcp_user_has_paid_membership() ) : ?>
    	<p>Content inside here would only be visible to active paid and active free subscribers.</p>
    <?php else : ?>
    	<p>Content inside here would display if the above condition is not met.</p>
    <?php endif; ?>

    Also, reading the sentence about “active paid and active free subscribers” are you sure you didn’t mean to use the rcp_user_has_active_membership function instead of rcp_user_has_paid_membership?

    The rcp_user_has_paid_membership check would exclude active free subscribers.

    Thread Starter Chris Raymond

    (@chrisraymond)

    Hi @lelandf – Thanks for the response, it’s much appreciated. Any idea why the custom message added within the Restrict content plugin is not displaying when using the php method? I don’t mind added a message via the template, but curious is something with my setup is affecting the plugins ability to render the text. Thanks again.

    Invoking the rcp_user_has_paid_membership function does not do anything other than return a boolean value: true or false.

    If true, then execution within the conditional block continues. That’s when the “Content inside here would only be visible […]” message displays.

    In other words, the custom message was not displaying because the code as originally written did not include instructions for that particular task.

    Thread Starter Chris Raymond

    (@chrisraymond)

    Makes sense now, thank you for the clarification. Much appreciated.

    Thread Starter Chris Raymond

    (@chrisraymond)

    @lelandf Just to be clear, our issue is that we need to show the restriction message which I set in the plugin settings for non paying users(visitors not logged in)

    Which does automatically populate message to pay for full content if we use short code in a test post. But when using our short code in custom template it’s not working. That’s why we wrapped our block in this condition by using that ‘rcp_user_has_paid_membership()’ function. Using this code is working as our block is hidden for non-paying users.

    Now the issue is that we need to show that message for non-payng users, is there is any function exists which can return the restriction message to which we set in plugin settings?

    Or are we using the wrong function? If I am doing wrong then please let me know which function I need to use? Thanks again.

    You could consider simply typing the message out in the code, like in my first example. Saves a trip to the database, especially if the message is not going to ever change.

    As for another function to dynamically retrieve the restricted content message, check out the rcp_get_restricted_content_message function. It’s in the core/includes/misc-functions.php file if you want to read it in full.

    It’s not wrong to not use it. It’s all about how exactly you want your site to behave.

    Since it sounds like you do want to dynamically pull the message, the PHP implementation would be something like this:

    <?php if ( rcp_user_has_paid_membership() ) : ?>
    	<p>Content inside here would only be only visible to active paid subscribers.</p>
    <?php else : ?>
    	<?php echo rcp_get_restricted_content_message(); ?>
    <?php endif; ?>

    Functions are generally supposed to be single-purpose. So in this case, you’d just be using two functions: one to determine if the user has a paid membership, and one to display the restricted content message.

    Thread Starter Chris Raymond

    (@chrisraymond)

    @lelandf Thanks for this, that worked perfectly. Much appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Restricted Content Message Problem’ is closed to new replies.