Page 1 of 2
What I desperatly need.
Posted:
August 23rd, 2011, 8:20 am
by twaycaster
I watch the videos for custom capabilies and the video code is totally different from the code under the api/scripting -- advanced conditionals.
I need a code from advanced conditionals and content dripping all wrapped up in one, That way it all works together.
can someone please help me with this, either tell me which code to use (the one from the video, or the stuff under the conditionals page) and if it is the stuff in the page can someone please give me the basics on where to put it and implement it.
and where in the world to put the content dripping code, as well as how to specify which pages to drip at each increment.
Thanks
Trinity
Re: What I desperatly need.
Posted:
August 23rd, 2011, 6:15 pm
by Cristián Lávaque
You specify the page that drips because it's the page you add the condition to. What are the conditions you want for your page? What level/ccap and time after payment?
Re: What I desperatly need.
Posted:
August 23rd, 2011, 7:11 pm
by twaycaster
I need this
ccap: group A
at registration Group A gets access to pages 1 2 and 3
at 7 days, they are dripped access to pages 3 4 and 5
at 14 days they are dripped access to pages 6 7 and 8
at 21 days they are dripped access to pages 9 10 and 11
at 28 days they are dripped access to page 12
I have looked at all the examples I could find and I just do not understand how to do it, I need someone to give me a sample code that resembles the basics I what I need to use to put it all together.
I would like to be able to place the code in the function.php page and let it go site wide instead of doing independant pages. (I saw that in the advanced conditionals video.)
Re: What I desperatly need.
Posted:
August 23rd, 2011, 11:33 pm
by Cristián Lávaque
I believe you mean the Custom Capabilities video, the second segment.
http://youtu.be/h7zBH938VbAThe explanation Jason gives there to add the customization is pretty clear, I don't think I can say it better easily.
Now, to add the content dripping to that, just add it using PHP conditions as shown in its documentation in combination with a tag as he shows for the ccaps.
WP Admin -> s2Member -> API / Scripting -> Content DrippingThe tag is what lets you identify which post/page to apply that condition to. If you don't want to use tags to identify the posts, then you'll have to use the conditionals in the posts themselves.
Re: What I desperatly need.
Posted:
August 24th, 2011, 7:31 am
by twaycaster
With ccaps, the code he uses is different then the code under s2member / scripting
and in dripping, I do not see where I put in which pages to drip when.
Re: What I desperatly need.
Posted:
August 25th, 2011, 12:51 am
by Cristián Lávaque
Maybe you can get a freelance developer to help you. You can try jobs.wordpress.net, oDesk.com or eLance.com.
Re: What I desperatly need.
Posted:
August 25th, 2011, 8:39 am
by twaycaster
Thats a shame, I figured with this huge community someone would have already worked out some base code for this. I will go outside of the support forums and check with a freelancer then.
Re: What I desperatly need.
Posted:
August 29th, 2011, 11:31 am
by Cristián Lávaque
twaycaster wrote:With ccaps, the code he uses is different then the code under s2member / scripting
That's because there are several ways to write the codes for the conditions. In the ccaps video he gives an more advanced example of a condition in PHP in one of the theme's files.
All of them, the ones in the videos or the ones in the Scripting API's docs, are just examples that you can copy or modify if you know what you're doing. Since that seemed to confuse you, I assumed you're not very experienced with coding and is why I suggested you look for help from a developer.
The simpler way to use conditionals is with shortcodes, but these too require a logic similar to coding PHP.
WP Admin -> s2Member -> API / Scripting -> Simple/Shortcode Conditionalstwaycaster wrote:and in dripping, I do not see where I put in which pages to drip when.
There isn't a Content Dripping are in your admin side where you manage content dripping at the moment. You drip the content using the conditionals right where the content you want to drip is. So in a page that has content to be shown after 2 weeks, right there you add the condition that checks if the user has been one for more than two weeks before showing the content to him.
I hope that helps.
Re: What I desperatly need.
Posted:
August 29th, 2011, 11:41 am
by twaycaster
Thanks so much for your reply,
I am actually pretty decent at coding, but I look at this and I wonder, can I add all the conditionals in function.php? including dripping?
The only thing is I do not see any example on how to list pages to be dripped. that is my biggest confusion.
Re: What I desperatly need.
Posted:
August 29th, 2011, 5:35 pm
by Cristián Lávaque
Ah, I see now what you mean.
Well, if you want to check all pages from a single place (like functions.php, instead of in each page), you can have an array of page IDs to check in the condition for each drip.
Does that help?
Re: What I desperatly need.
Posted:
August 29th, 2011, 5:39 pm
by twaycaster
Can u give a example of where to put the page ids in the code
Re: What I desperatly need.
Posted:
August 30th, 2011, 1:53 pm
by Jason Caldwell
Thanks for the heads up on this thread.twaycaster wrote:ccap: group A
at registration Group A gets access to pages 1 2 and 3
at 7 days, they are dripped access to pages 3 4 and 5
at 14 days they are dripped access to pages 6 7 and 8
at 21 days they are dripped access to pages 9 10 and 11
at 28 days they are dripped access to page 12
You might do something like this inside the
functions.php file for your WordPress theme.
- Code: Select all
<?php
add_action ("template_redirect", "my_s2_custom_capabilities");
function my_s2_custom_capabilities ()
{
if (current_user_can ("access_s2member_ccap_a"))
{
if (is_page (array (1, 2, 3)))
{
}
else if (is_page (array (3, 4, 5)) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < 7)
{
wp_redirect ("http://example.com/not-yet-available-to-you/") . exit ();
}
else if (is_page (array (6, 7, 8)) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < 14)
{
wp_redirect ("http://example.com/not-yet-available-to-you/") . exit ();
}
else if (is_page (array (9, 10, 11)) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < 21)
{
wp_redirect ("http://example.com/not-yet-available-to-you/") . exit ();
}
else if (is_page (12) && S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < 28)
{
wp_redirect ("http://example.com/not-yet-available-to-you/") . exit ();
}
}
else {
wp_redirect ("http://example.com/signup-for-group-a/") . exit ();
}
}
?>
You could also place this code inside:
/wp-content/mu-plugins/s2-hacks.php( whichever is easier for you ).
Re: What I desperatly need.
Posted:
August 30th, 2011, 3:55 pm
by twaycaster
Oh Jason!! you are my hero.
Thank you so much for helping me with this. I had already made up my mind and purchased s2pro last night, this seals the deal and will allow me to develop everything I need with my sites.
Thank you so much
Trinity
Re: What I desperatly need.
Posted:
August 30th, 2011, 6:18 pm
by Jason Caldwell
You are VERY welcome. Thanks for your purchase too!
Re: What I desperatly need.
Posted:
August 30th, 2011, 11:04 pm
by Cristián Lávaque
Thanks, Jason.
Here's a modified version using an array for the drips that'd make it quick to edit them.
- Code: Select all
<?php
add_action ('template_redirect', 'my_s2_custom_capabilities');
function my_s2_custom_capabilities() {
$drips = array(
7 => array(3, 4, 5),
14 => array(6, 7, 8),
21 => array(9, 10, 11),
28 => array(12),
);
if (current_user_can('access_s2member_ccap_a')) {
foreach ($drips as $drip_day => $drip_pages) {
if (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < $drip_day && is_page($drip_pages)) {
wp_redirect('http://example.com/not-yet-available-to-you/');
exit;
}
}
} else {
wp_redirect('http://example.com/signup-for-group-a/');
exit;
}
}
?>
I hope it helps.
Re: What I desperatly need.
Posted:
August 30th, 2011, 11:09 pm
by Jason Caldwell
Very nice!
Re: What I desperatly need.
Posted:
August 31st, 2011, 8:18 pm
by twaycaster
Looking at the last code posted by Chris, are all the marks in the correct placements? they just seem off from all the other code I have seen.
I have tried adding both sets of codes as is to functions.php and it has created an error on my site, I am going to add it to s2-hacks.php in the mu-plugins folder but want to verify the code is correct (Other then the websites ofcourse. I know I have to replace those with the sites I am using the code in.
Thanks guys for the help
Trinity
Re: What I desperatly need.
Posted:
August 31st, 2011, 8:48 pm
by Jason Caldwell
Hi Trinity. Yes, they both look good from this end. What's the error that you got?
Re: What I desperatly need.
Posted:
September 1st, 2011, 1:49 am
by Cristián Lávaque
Make sure you have no spaces or empty lines before the
<?php or after the
?>.
You'd have to update the URL with yours, and the page IDs with the actual ones you create for the drips.
https://wordpress.org/extend/plugins/wp-show-ids/I can understand it looks off, here's it's again with the opening curly brackets in their own lines:
- Code: Select all
<?php
add_action ('template_redirect', 'my_s2_custom_capabilities');
function my_s2_custom_capabilities()
{
$drips = array(
7 => array(3, 4, 5),
14 => array(6, 7, 8),
21 => array(9, 10, 11),
28 => array(12),
);
if (current_user_can('access_s2member_ccap_a'))
{
foreach ($drips as $drip_day => $drip_pages)
{
if (S2MEMBER_CURRENT_USER_PAID_REGISTRATION_DAYS < $drip_day && is_page($drip_pages))
{
wp_redirect('http://example.com/not-yet-available-to-you/');
exit;
}
}
}
else
{
wp_redirect('http://example.com/signup-for-group-a/');
exit;
}
}
?>
Does that help?
Re: What I desperatly need.
Posted:
September 1st, 2011, 12:40 pm
by twaycaster
anytime I use either of these codes, I either get a error 500 website not available or a generic error this site is under maintenence or cannot connect to the server. the minute I remove the code, it goes back to working correctly.
I guess I will have to do some php research and see where I am messing up with the code. I am 99% sure it is the copy and paste that messes up the code and something is not going in the right place. If either of you would like to log onto my site and verify it I would gladly let you.
Re: What I desperatly need.
Posted:
September 1st, 2011, 1:12 pm
by Jason Caldwell
I'm putting the file together for you. Please unzip the attached file, and upload s2-hacks.php to your /wp-content/mu-plugins/ directory. If you still have an error, please post the full error message and we'll have a look for you.
Re: What I desperatly need.
Posted:
September 1st, 2011, 3:36 pm
by twaycaster
Thanks Jason;
sadly I uploded the file and when I log out I get webpage not available.
http://www.holistic-living-today.comPlease help.
I tried to log in with a test user id and it would not load the page and gave me webpage not available, so I got via FTP and remove the s2-hack.php and viola, website is back up and running, fast and responsive again.
I dunno.
Re: What I desperatly need.
Posted:
September 1st, 2011, 5:08 pm
by Jason Caldwell
Did you change the redirection URLs in the code sample?
- Code: Select all
http://example.com/not-yet-available-to-you/
http://example.com/signup-for-group-a/
If so, please post the revised PHP file that you're using.
Re: What I desperatly need.
Posted:
September 1st, 2011, 7:25 pm
by twaycaster
Here you go, I have changed over everything I was supposed to and this was the finished product. The minute I upload this my website becomes super sluggish and if I log out it flips to webpage not available, and no pages will load.
Re: What I desperatly need.
Posted:
September 1st, 2011, 8:40 pm
by Jason Caldwell
Thanks for the reply.
Your file has an extra line break at the bottom, right after ?>
Please make sure there are no leading/trailing spaces,tabs,line breaks before or after <?php ?>
If you continue to have trouble, I would double-check that the pages you are redirecting to, are not somehow redirecting the browser again, thereby creating an endless loop of redirections.