Does membership can manage this ?

Hi !

I will have to work on a new project, an online newspaper.

Simple huh ? :wink:

Well no.

This site requires a subscription system BUT...

Only THIS Month publication must be protected (or 2 last monthes), all archive must be free.

Does Membership can manage that option ?

And, moreover, would need that the protected posts mentions "you want to read more so subscribe" inside the post, that would of course disapear after X days....

By the way, the must would be to be able to buy THIS post or to subcribe for all posts...

Well, a newspaper though :wink:

Thanks !

  • Ash
    • WordPress Hacker

    Hello there

    I hope you are well today and thanks for asking the question.

    It should be a little bit tricky. Please follow the following steps:

    1. Create a category for archive posts, e.g. "older" and find the category for it. Assume it's ID is 3.
    2. Through membership plugin, create a free level and set positive rule to access that category (older).
    3. Now add the following line into your functions.php:

    add_action('init', 'add_categories');
    function add_categories() {
    	$args = array('posts_per_page'   => -1);
    	$posts_array = get_posts( $args );
    	foreach($posts_array as $post) {
    		$post_date = date_parse($post->post_date);
    		$post_date['month'] = $post_date['month'] == 12 ? 0 : $post_date['month'];
    		$current_month = date('m');
    		if($current_month > $post_date['month'] && get_post_type($post->ID) == 'post') {
    			$post_categories = wp_get_post_categories( $post->ID );
    			array_push($post_categories, 3);
    			wp_set_post_categories( $post->ID, $post_categories );
    		}
    	}
    }

    This code will check every post that is published in previous month and set category "older" to that post. Now those posts should be accessible for the free level users.

    Please let me know if it is helpful and feel free to ask more question if you have.

    Cheers
    Ash

  • Aphrodite
    • The Reaper

    Hello !

    Well i understand the process but in fact i am not sur it is possible to apply it because all post MUST remain in their category, and that would require a manual action from the newspaper owner. Not really doable...

    Perhaps playing with custom fields...

    I understand that will not be simple anyway :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.