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.

Activating links based on dripped content

Home Forums Community Forum Activating links based on dripped content

This topic contains 20 replies, has 2 voices. Last updated by  Cristián Lávaque 4 years, 2 months ago.

Topic Author Topic
Posted: Monday Oct 1st, 2012 at 7:33 pm #27163
cassel
Username: cassel

Maybe i will have to get a work around but if i drip content (as i am planning), i currently have all the tutorials listed either on an “index” page with a preview of each tutorial, or a text list with links. Those are available to anyonoe who is CURRENTLY a full member but i want to change that for NEW members so they have fewer tutorials to start and drip them weekly.

I could conceivably have say, a list of 20 tutorials conditional to having joined for 7 days, then the 21st, conditional to having joined for 14 days, and so on. This is feasible but not practical as the tutorials are grouped by theme (sub-categories) and the order they are presented is not linear: i can have one tut in category A, then one in category D, then one in category B, and then another one in category B, and so on.

Currently, i have previews in BW for tutorials that are not YET available, but coming soon. There is no conditional as there is… no link yet. But if i want to drip the content that is already there, is there a way to have the image display differently WITH the link conditional to the dripped content? It looks like it would be a LOT of php since i have, so far, over 60 tutorials to “drip”.

Can you think of a simpler method? I would hate to link to a page and the member would land on it with a message “Sorry, this is not yet available”. How would the member know what IS available in the long list of tutorials?

List Of Topic Replies

Viewing 20 replies - 1 through 20 (of 20 total)
Author Replies
Author Replies
Posted: Tuesday Oct 2nd, 2012 at 7:30 am #27207

Well, the more complicated the combinations of requirements, the longer the conditions will be. You still need the conditionals.

What you could to to save writing some code, and standardising it, is define a function to check the things you usually check. Then you could just feed it certain values for the function to return [hilite mono]true[/hilite] or [hilite mono]false[/hilite]. For example:

[hilite pre_code]
function my_conditionals($level = '', $ccaps = array(), $drip_day = 0) {
// ...
[/hilite]

Then you can use that in your condition like:

[hilite pre_code]
if (my_conditionals(1, array(), 14))
echo "You can view this because you've been at Level 1 for more than two weeks.";
[/hilite]

But that’s just the idea, it needs refinement. I’m talking in general terms because I don’t have the exact things you’re checking in your conditions, but it should help. Ask your developer about it, he should be able to take it from here.

I hope it helps. :)

Posted: Tuesday Oct 2nd, 2012 at 7:39 am #27208
cassel
Username: cassel

Thanks.

Posted: Tuesday Oct 2nd, 2012 at 3:47 pm #27249

No problem. :)

Posted: Wednesday Oct 10th, 2012 at 7:47 am #27979
cassel
Username: cassel

I am not fluent in PHP language so i need a little “translation” here.
In the other thread: http://www.s2member.com/forums/topic/content-dripping-timesstamp-ccaps/ there was a long and complex php code for content dripping and so on. Do you mean it could be replaced by a function like in your previous post?

In simple English, i would like to have a “conditional” that will determine if the condition is true or false so whatever i want to display, does display at that particular time. Here is what i need translated in php:

if (member is Level1 AND has “element” ccap) OR (member is Level2 AND has “element” ccap” AND has been a level 2 member for x days):
Display the content

Can that be put in that function you mentioned above?

Then, where does the function go?

Then, what will the actual command calling the function look like?

I think that is the only piece i am missing and then, i`ll be good to go.

Posted: Wednesday Oct 10th, 2012 at 10:00 pm #28064
cassel
Username: cassel

I made up this code to try to translate into PHP:

<?php if (current_user_can(“access_s2member_level1") && current_user_can("access_s2member_ccap_element") 
    || ((current_user_can(“access_s2member_level2") && current_user_can("access_s2member_ccap_element") && s2member_paid_registration_time("level2")>=7){ ?>
 Display what is supposed to be dripped to the level 2 members, but available to the level 1 members already
<?php } ?> 

How would the function be written with it (if it is even correct to start with).
Then, how is it called back when i need it?

Posted: Friday Oct 12th, 2012 at 7:32 am #28210

Hmm… That condition seems wrong. You can try this:

[hilite pre_code]

Show if Level 1, or if Level 2 for more than a week.

[/hilite]

Please compare it carefully with the one you posted to see what I changed.

[hilite mono]s2member_paid_registration_time[/hilite] returns a timestamp, so you have to compare it with another one. http://php.net/strtotime

[hilite mono]current_user_can[/hilite] wouldn’t work for you, because a Level 2 user can access level 1 content, so it’d always be true. So you need to use [hilite mono]current_user_is[/hilite] to avoid the incremental access with levels in your condition. [hilite path]Dashboard -› s2Member® -› API / Scripting -› Advanced PHP Conditionals -> Example 3[/hilite]

You were missing a parenthesis to group the conditions correctly. Instead of just adding it, I rearranged the conditions, though.

Yes, you could create a function for it. I’d put it in the must-use plugins dir (/wp-content/mu-plugins/). http://www.tizag.com/phpT/phpfunctions.php

I hope that helps. :)

Posted: Friday Oct 12th, 2012 at 7:49 am #28216
cassel
Username: cassel

I was thinking today that whether the user is Level 1 or Level 2, they both have to have “element” as a ccap. Do i have to add it to this formula or can i just protect the page itself with that ccap?

Also, in order to give me the option to give a free membership, can i skip the paid_registration and only have registration? Otherwise, how would i be able to “give” a membership (say for testing, for showing someone around or for a contest prize)?

  • This reply was modified 4 years, 2 months ago by  cassel.
Posted: Friday Oct 12th, 2012 at 8:00 am #28220

You could just check if the user has the ccap, that’s fine, but then you won’t be dripping it after 7 days for Level 2 users.

If you want to see if the user is registered, check if he’s logged in.

Posted: Friday Oct 12th, 2012 at 8:08 am #28222
cassel
Username: cassel

Hum… not sure it matches what i was asking. If the only ccap i have for the Level 2 is “element”, can i just drip based on Level 2 registration date? If the user does not have the “element” ccap, the page simply would not display at all. Or maybe i am understanding it wrong? I was just looking at a way to take up less space!

And for the free registration, it is not a matter of being registered, but “be registered at Level 2”, so i was wondering if i could use
s2member_registration_time(‘level2’)
instead of
s2member_paid_registration_time(‘level2’)

Also, looking at your corrected code, you have
“element” ccap AND Level 1 OR Level 2 with the time delay

Does that really do the same as
(“element ccap AND Level 1) OR (“element ” ccap AND Level 2 with the time delay)

Or should it be something like this
“element” ccap AND (Level 1 OR Level 2 with the time delay)
to make sure that the “element” ccap is a necessary condition whether it is for Level 1 or Level 2?

I see the correction you did, but not sure it means the same thing i intended.

  • This reply was modified 4 years, 2 months ago by  cassel.
  • This reply was modified 4 years, 2 months ago by  cassel.
Posted: Friday Oct 12th, 2012 at 8:40 am #28233

Or should it be something like this
“element” ccap AND (Level 1 OR Level 2 with the time delay)
to make sure that the “element” ccap is a necessary condition whether it is for Level 1 or Level 2?

That’s what I did. Look at the way I grouped the conditions with the parenthesis. :)

Posted: Friday Oct 12th, 2012 at 8:49 am #28236
cassel
Username: cassel

Darn, and that is what i was looking at too. Time to put on my glasses! Thanks for your patience!

Posted: Friday Oct 12th, 2012 at 9:02 am #28238

:)

Posted: Friday Oct 12th, 2012 at 10:11 am #28243
cassel
Username: cassel

You said in another thread that i can replace “days” by “minutes” or “hours”. Can i also use “weeks” instead of coming up with 364 days or 84 days? It would be a bit easier to calculate to say 52 weeks or 12 weeks, and so on.

Posted: Saturday Oct 13th, 2012 at 12:53 am #28295

Yeah, you can do [hilite mono]strtotime('-1 week')[/hilite] instead of ‘-7 days’, same for ‘-1 year’ instead of ‘-52 weeks’, etc.

Posted: Saturday Oct 13th, 2012 at 11:18 am #28336
cassel
Username: cassel

Thanks. Silly question here, but can you use “week” and “weeks” interchangeably? Or is only one correct?

Posted: Saturday Oct 13th, 2012 at 4:35 pm #28348

I think it’s fine, but you could test it to be sure.

[hilite pre_code]

[/hilite]
Posted: Sunday Oct 21st, 2012 at 5:07 pm #29218
cassel
Username: cassel

I got the code but i am not sure where i should put the function. You mention putting it in the /mu-plugins/ but do i add that to the s2-hacks.php file or create a new file? I am convinced i had to do something like that last year, but it is way to far back to remember.

Just a little pointer?

Posted: Monday Oct 22nd, 2012 at 9:34 am #29257

You can add code to the existing hacks file, or create a new file, either one is fine.

Posted: Monday Oct 22nd, 2012 at 9:56 am #29260
cassel
Username: cassel

Meaning the s2-hacks.php file?

Posted: Tuesday Oct 23rd, 2012 at 5:26 am #29362

Yeah, that’s the one you were asking about, right? As long as it’s in the mu-plugins directory, it’ll be loaded. All your hacks can be in a single file, or in separate ones.

Viewing 20 replies - 1 through 20 (of 20 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.