latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

conditional tag

Home Forums Community Forum conditional tag

This topic contains 5 replies, has 3 voices. Last updated by  Cristián Lávaque 3 years, 5 months ago.

Topic Author Topic
Posted: Saturday Jul 6th, 2013 at 10:50 pm #53079
David Roberts
Username: inbama

Need some help setting up this simple comment box to be seen only to registered/logged in users. Can someone tell me how to make this work? The following shows nothing:

[s2If current_user_can(access_s2member_level0)]
<div> </div>
[/s2If]

List Of Topic Replies

Viewing 5 replies - 1 through 5 (of 5 total)
Author Replies
Author Replies
Posted: Tuesday Jul 9th, 2013 at 4:35 am #53154
Bruce
Username: Bruce
Staff Member

Thank you for your inquiry.

I’m very sorry for the delay in response. Thanks for your patience over the weekend.


I’m assuming you’re editing your theme’s files directly, so you’d use s2Member’s Advanced PHP Conditionals. Specifically, you’d do something like this:

<?php if(is_user_logged_in()) { ?>
<div data-href="http://example.com" data-width="280" data-num-posts="10" data-colorscheme="dark"> </div>
<?php } ?>

Does that make work for you?

Posted: Tuesday Jul 9th, 2013 at 9:47 am #53180
David Roberts
Username: inbama

I’m not sure I understand. I may not have asked the question properly… I love using the shortcodes for conditionals provided, and the’re such a time-saver. We’re using them without issue over and over; but this time, I wanted to add html code, to show a comment box (used to chat with other logged in users). Does the php you shared address the ability to add html, in order to use the conditional in that way?

To clarify, we are using a custom sidebar where non-members see an invitation to register, etc, and logged-in users to see the comment box. The conditionals we are adding work fine, except when I add an html code within the conditional. The html code simply doesn’t show the comment box when inserted within the conditional.

Thank you for your time!

Posted: Thursday Jul 11th, 2013 at 9:27 am #53292
Bruce
Username: Bruce
Staff Member

I’m very sorry for the delay. I missed this thread yesterday.

I’m not sure I understand. I may not have asked the question properly… I love using the shortcodes for conditionals provided, and the’re such a time-saver. We’re using them without issue over and over; but this time, I wanted to add html code, to show a comment box (used to chat with other logged in users). Does the php you shared address the ability to add html, in order to use the conditional in that way?

I see so the problem is not that the conditionals don’t work, but that the comment field does not show up when you use conditionals?

It sounds to me like you have to tell your theme to use the field when you do that. I’d recommend talking to your theme’s developer about that. s2Member should be adding this field early enough for your theme to pick up on it, but I’m not sure about what’s necessary to make it work with your theme. Sorry about that.

Posted: Thursday Jul 11th, 2013 at 9:24 pm #53326
David Roberts
Username: inbama

That is not what I’m saying… I’m not referring to the wordpress comment box. The code not functioning ‘is’ a comment box, one we’re adding to the sidebar.

This new comment box we are introducing works perfectly when it is “not” wrapped in an s2member conditional. All I need to know is why won’t it work when I add the conditional I’m using. Could I be using the wrong one? Is there another wrap I can put the same code, or are there some things that won’t work in conditionals?

The code I’m using works perfectly on our site when added anywhere on the site. And also, s2member conditionals work perfectly on our site. The problem comes in when I add this code within the conditional I originally shared, Once I put the code inside that conditional, ‘Nothing’. I don’t understand why it isn’t working.

I’m getting the code from here: https://developers.facebook.com/docs/reference/plugins/comments/

Posted: Saturday Jul 13th, 2013 at 6:49 am #53388

David, I don’t know why the HTML would break when inside the shortcode conditional, but I’d try the PHP conditional to see if it doesn’t break then. See: [hilite path]Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals[/hilite]

I went to the page you linked to and noticed that the code generated for the Comments Box, includes a class that your code doesn’t: [hilite mono]class="fb-comments"[/hilite]. Maybe you’re missing that for it to work? Don’t know, just thought I’d mention it.

<div class="fb-comments" data-href="http://example.com" data-width="470" data-num-posts="10"></div>

Also, there’s some JavaScript that goes along with it, did you add it to your page as well?

I hope that helps. :)

Viewing 5 replies - 1 through 5 (of 5 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.