Page 1 of 1

Advanced content hide/reveal

PostPosted: October 5th, 2011, 4:10 pm
by Vahka
I have an idea to implement additional content hide/reveal function. That means every new registered member can see new content step by step, pending on join date. Have someone experience with this kind of Wordpress application or can s2meber resolve it?

Re: Advanced content hide/reveal

PostPosted: October 5th, 2011, 9:09 pm
by surochek
That's what I've been trying to do with this, but I'm so rusty I can't see why I get an error:

Code: Select all
<?php if(s2member_registration_time() > 0 and current_user_can(access_s2member_ccap_life) ){ ?>
        This will be displayed to all Members that have registered at some point.
    <?php } ?>
   <?php elseif (s2member_registration_time()> 0 && !current_user_can(access_s2member_ccap_life) ){ ?>
    Please be patient. Your next lesson will be available in due time.
    <?php } ?>
   <?php else { ?>
    Please register for this course to see the lessons.
<?php } ?>


I get the warning:
Parse error: syntax error, unexpected T_ELSEIF in /home/content/89/8190889/html/wordpress/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 39

Re: Advanced content hide/reveal

PostPosted: October 6th, 2011, 2:47 am
by Vahka
However, find it - S2M include solution. In API/Scripting section just open s2Member Content Dripping and copy the php code. ;)

Re: Advanced content hide/reveal

PostPosted: October 6th, 2011, 4:23 am
by Cristián Lávaque
Vahka, right. :) WP Admin -> s2Member -> API / Scripting -> s2Member Content Dripping

surocheck, let me know if this also gives you the error:

Code: Select all
<?php if (s2member_registration_time() > 0 && current_user_can(access_s2member_ccap_life)) { ?>
This will be displayed to all Members that have registered at some point.
<?php } elseif (s2member_registration_time() > 0 && !current_user_can(access_s2member_ccap_life)) { ?>
Please be patient. Your next lesson will be available in due time.
<?php } else { ?>
Please register for this course to see the lessons.
<?php } ?>


I'm not sure about the logic, though. You say in the first block that it's displayed to anyone that registered at some point, but you don't mention they need the "life" custom capability too. The second block is for those without the custom capability "life" but the message asks to be patient, but the condition doesn't check for a day later.

Re: Advanced content hide/reveal

PostPosted: October 6th, 2011, 10:32 am
by surochek
Actually, since the content is protected both at level 0 and by a custom capability, I think I only need this:
Code: Select all

    <?php if (s2member_registration_time() > 0 && current_user_can(access_s2member_ccap_life)) { ?>
    This will be displayed to all Members that have registered at some point.
    <?php } ?>


Then, for successive days:
Code: Select all

    <?php if (s2member_registration_time() > 1 && current_user_can(access_s2member_ccap_life)) { ?>
    This will be displayed to all Members that have registered at some point.
    <?php } elseif (s2member_registration_time() < 1 && current_user_can(access_s2member_ccap_life)) { ?>
    Please be patient. Your next lesson will be available in due time.
    <?php } else { ?>
    Please register for this course to see the lessons.
    <?php } ?>

Re: Advanced content hide/reveal

PostPosted: October 9th, 2011, 3:16 pm
by surochek
However, if anyone registers for a second course later, the content of that second course will be revealed all at once, and I'm back to not knowing what to do.

Re: Advanced content hide/reveal

PostPosted: October 11th, 2011, 12:28 pm
by Cristián Lávaque
But if you're managing the access to the course using custom capabilities, you can create new conditionals for it to drip it, just like you do for the first one. :)

Re: Advanced content hide/reveal

PostPosted: October 11th, 2011, 1:45 pm
by surochek
It's *my* logic that's not functioning these days.

In other words,
Code: Select all
<?php if (s2member_registration_time() > 0 
     
&& current_user_can(access_s2member_ccap_life)) { ?>

will affect ccap "life" but not ccap "lifeTwo"
whereas
Code: Select all
<?php if (s2member_registration_time() > 0 
    
&& current_user_can(access_s2member_ccap_lifeTwo)) { ?>

will affect ccap "lifeTwo" but not ccap "life"

Even though the member is always on level 0...

So I can drip them successively to the same member?

(weird kind of beginner at coding here, yes, apologies for what may be a very obvious statement)

Re: Advanced content hide/reveal

PostPosted: October 12th, 2011, 3:22 pm
by Cristián Lávaque
I see your problem. Don't worry, you're doing well for a beginner. :)

Code: Select all
<?php if (s2member_registration_time() > && (current_user_can(access_s2member_ccap_life) || current_user_can(access_s2member_ccap_lifeTwo))) { ?>


Let me know if this helps.