PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Drip Feeding Posts or Pages to menu?

s2Member Plugin. A Membership plugin for WordPress®.

Drip Feeding Posts or Pages to menu?

Postby KirkWard » October 26th, 2010, 11:44 am

Is it possible for s2 to control the release of a post or page on a per member basis, using something like the time delay function of the Wordpress "Publish" widget?

I would like to restrict the visiblity of a particular post or page until a member has been registered at the protected level for x period of time. Using the built in features of Wordpress would be easier than having to create a menu on a single protected page. It would also allow more freedom in the use of most Wordpress themes.

Thanks
User avatar
KirkWard
Experienced User
Experienced User
 
Posts: 61
Joined: October 22, 2010

Re: Drip Feeding Posts or Pages to menu?

Postby Jason Caldwell » October 29th, 2010, 2:35 am

Thanks for the great question/suggestion.

No, s2Member does NOT make this particular feature available as of v3.2.9. s2Member's ability to handle Content Dripping is still limited to its API Constants and documentation made available in your Dashboard under: s2Member -> API Scripting -> Content Dripping.

That being said, you could certainly implement this in a few different ways. Here is one idea for you.

Using s2Member's Meta Box panel on your Post/Page editing forms, you could require specific Custom Capabilities for Posts/Pages that you plan to drip. So let's look at how I might handle this.


Title: An Example Post A
- require Custom Capability: 30days

Title: An Example Post B
- require Custom Capability: 60days

Title: An Example Post C
- require Custom Capability: 90days


So configuring this is pretty simple, as all of that functionality is already built-in with s2Member installed. The only thing left to deal with, is how to assign these Custom Capabilities on a per-User basis, based on how long they've been registered with your site.

You can use the sample script provided below as a starting point:
Save it here: /wp-content/mu-plugins/my-s2-cron-job.php
Code: Select all
<?php
function my_s2_cron_job 
()
    {
        if ($_GET["my_s2_cron_job"])
            {
                foreach (get_users_of_blog () as $user)
                    {
                        $user = new WP_User ($user->ID);
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
                            $user->add_cap ("access_s2member_ccap_30days");
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
                            $user->add_cap ("access_s2member_ccap_60days");
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
                            $user->add_cap ("access_s2member_ccap_90days");
                    }
                exit ();
            }
    }
add_action ("init", "my_s2_cron_job");
?>

You can run this script as a Cron job, once per day:
Code: Select all
http://www.example.com/?my_s2_cron_job=1
OR: http://www.example.com/path/to/wordpress/?my_s2_cron_job=1
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Drip Feeding Posts or Pages to menu?

Postby KirkWard » October 29th, 2010, 7:17 am

This is fantastic.
User avatar
KirkWard
Experienced User
Experienced User
 
Posts: 61
Joined: October 22, 2010

Re: Drip Feeding Posts or Pages to menu?

Postby KirkWard » October 29th, 2010, 9:13 am

bump: For clarification.

Title: An Example Post C
- require Custom Capability: 90days

If I implement this custom capability for the Bronze level, what happens when the viewer upgrades to the Silver level? Are they bumped back to ...
Title: An Example Post A
- require Custom Capability: 30days
User avatar
KirkWard
Experienced User
Experienced User
 
Posts: 61
Joined: October 22, 2010

Re: Drip Feeding Posts or Pages to menu?

Postby plrblockbusters » December 7th, 2010, 7:35 pm

Hi Jason,

Tried using the code mentioned below and unfortunately did not have any luck with dripping the content as shown in your example. Here are the steps I performed below:

1. Added the 30days, 60days and 90days to the needed post in the (Require Custom Capabilities) section.
2. Then copied the code mentioned below into a (my-s2-cron-job.php) file and placed it in the plugins section of my wordpress.
3. Created a cron job per your suggestion to run once a day.

If I have missed something please let me know. If I can get this to work, I'm planning on purchasing the Pro version as well.

Regards,

-Juan
PLRBlockbusters.com
Code: Select all
<?php
function my_s2_cron_job ()
    {
        if ($_GET["my_s2_cron_job"])
            {
                foreach (get_users_of_blog () as $user)
                    {
                        $user = new WP_User ($user->ID);
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
                            $user->add_cap ("access_s2member_ccap_30days");
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
                            $user->add_cap ("access_s2member_ccap_60days");
                        /**/
                        if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
                            $user->add_cap ("access_s2member_ccap_90days");
                    }
                exit ();
            }
    }
add_action ("init", "my_s2_cron_job");
?>
User avatar
plrblockbusters
Registered User
Registered User
 
Posts: 2
Joined: December 7, 2010

Re: Drip Feeding Posts or Pages to menu?

Postby plrblockbusters » January 4th, 2011, 4:28 pm

"bump"

Can you verify the code above. This would be great if I can make the drip content work correctly.

Thanks,

-Plrblockbuster
User avatar
plrblockbusters
Registered User
Registered User
 
Posts: 2
Joined: December 7, 2010

Re: Drip Feeding Posts or Pages to menu?

Postby smitchell360 » January 11th, 2011, 5:31 pm

I leveraged wp cron for this purpose ... in a simple plugin:

Code: Select all

<?php
/*
Plugin Name: [yourname] Cron Jobs
Version: 1.0
Description: Cron Jobs for [yoursite]
Author: [yourname]
*/

//handle registration/deregistration
register_activation_hook(__FILE__, 'yourname_activate');
register_deactivation_hook(__FILE__, 'yourname_deactivate');

//add actions
add_action('yourname_daily_event', 'yourname_daily');


function yourname_activate() {
   if (!wp_next_scheduled('yourname_daily_event')) {
      wp_schedule_event(time(), 'daily', 'yourname_daily_event');
   }
}

function yourname_deactivate() {
   wp_clear_scheduled_hook('yourname_daily_event');
}

function yourname_daily() {

   foreach (get_users_of_blog () as $user)
   {
      $user = new WP_User ($user->ID);
         
      /**/
      if (strtotime ($user->user_registered) <= strtotime ("-30 days"))
         $user->add_cap ("access_s2member_ccap_30days");
      /**/
      if (strtotime ($user->user_registered) <= strtotime ("-60 days"))
         $user->add_cap ("access_s2member_ccap_60days");
      /**/
      if (strtotime ($user->user_registered) <= strtotime ("-90 days"))
         $user->add_cap ("access_s2member_ccap_90days");
   }   

}


?>


User avatar
smitchell360
Experienced User
Experienced User
 
Posts: 28
Joined: January 4, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot] and 4 guests

cron