• Resolved Bradley Pirman

    (@bradley-pirman)


    We’re trying to lock down a template to specific “labels” only in MFM.

    If the member is signed in, we’re receiving a message but not the_content().

    What are we doing wrong?

    Thanks!

    Here’s our code:

    $response = sf_memberonly('[memberonly label="CITAPRIL2016"]');
    if ( $response == "") {
    	the_content();
    } else {
    	echo $response;
    }

    https://wordpress.org/plugins/memberfindme-login-connector/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author MembershipWorks

    (@sourcefound)

    Hi Bradley! This should have worked, what is the response/message you are getting?

    Thread Starter Bradley Pirman

    (@bradley-pirman)

    Hey there! Thanks for the response.

    I’m getting this in place of the content:

    “[administrator info: content below memberonly label=”CITAPRIL2016″]”

    But no content displays after that in the page. Only the footer and everything after the_content.

    <article id="post-3006" class="post-3006 page type-page status-publish hentry">
    
    					<h1 class="main_title">Coach Intensive Training — April 2016 – TESTING</h1>
    
    					<div class="entry-content">
    					[administrator info: content below memberonly label="CITAPRIL2016"]					</div> <!-- .entry-content -->
    
    				</article>
    Plugin Author MembershipWorks

    (@sourcefound)

    Hi Bradley Pirman! That is the message shown if you are logged in as a WordPress administrator so that is normal. Since you are testing for no response, this message causes the first IF statement to be false.

    You will need to test on a separate browser (not a separate tab/window) where you are logged in as a member with the appropriate permissions (ie. have the appropriate label and a renewal date that is sufficiently current).

    Thread Starter Bradley Pirman

    (@bradley-pirman)

    Okay so I think I’m misunderstanding what the plugin is returning to $response.
    I read the post here and thought that if the user had permissions, that $response would be empty. So then I was trying to display the_content if $response was empty.

    I’m looking for a way to show the_content if the user is authorized. Can you help me fashion my if() to do that?

    Thanks so much!
    /b

    Plugin Author MembershipWorks

    (@sourcefound)

    Hi Bradley Pirman! that is correct, the function will return an empty string given the parameter you pass it, if the user had permission as a member to access the content. However a WordPress administrator is not a member. So you should perform your testing on a separate browser, logged in as a member.

    Thread Starter Bradley Pirman

    (@bradley-pirman)

    GREAT! Nice to know the code was in line!
    This poses a problem when Administrators are viewing the page. I guess I could test for the “[Administrator…]” string in response instead of just the empty.

    future idea? maybe have “unauthorized” or similar message in $response if the user is unauthorized.

    Thanks so much for your help. Especially the prompt response!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘shortcode in template’ is closed to new replies.