• Resolved Eric Mann

    (@ericmann)


    I have a very specific feature I’d like to add to one of my blogs and I’m hoping there is either an existing plugin or someone out there who can help with the code.

    I’d like new posts (less than one month old) to be fully available on the blog to all users (registered and unregistered). However, I would like to restrict the blog so that, after a post is a month old, only the excerpt is available to ‘free’ users. I would like ‘premium’ users to still have access to the full post, though. How can I do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • This describes exactly what my situation is right now. The only difference is we want to do the reverse. If you find a solution, I would definitely be interested in knowing.

    I am also very interested. Let us see if someone has a solution for this one.

    am also interested in this, but for me, i need something to only hide some portions of an article from non-registered guests and ask them to register.

    for the previous requests, i found this: https://butlerblog.com/wp-members/

    am sure it will work for you, especially kenyadenola. let me knw if am right

    Thread Starter Eric Mann

    (@ericmann)

    I ended up having to write my own script, actually. On the main site page (index.php) I just swapped out the part of the loop referring to “the_content” with “the_excerpt”:

    <div class="post-content">
         <?php the_content(); ?>
    </div>

    Becomes

    <div class="post-content">
         <?php the_excerpt(); ?>
    </div>

    Then I changed the post page (single.php) so that, for the first 30 days a post is up, everyone can see it. After 30 days, you need to be registered and logged in (authenticated) to see anything but the excerpt:

    <div class="post-content">
          <?php the_content(); ?>
    </div>

    Becomes:

    <div class="post-content">
    <?php global $user_ID;
          get_currentuserinfo();
    ?>
    <?php $today=date(z); ?>
    <?php $postday=the_date('z', '', '', FALSE); ?>
    <?php if($today - 30 > $postday && $user_ID == '') {
          echo '<p style="font-size: 36px;"><center><a href="<?php bloginfo('url'); ?>/wp-login.php?action=register">Please Register!</a></center></p>';
          echo '<p style="font-size: 11px; font-family: Arial, Helvetica, sans-serif;">You must be a registered user to view this post.  Until you complete your registration, you will only be able to view an excerpt:</p>';
          the_excerpt();
    }
          else {
          the_content();
    }
    ?>
    <!--<?php the_content(); ?>-->
    </div>

    I hope that helps!

    Interesting solution, thanks ericmann ??

    p/s: Just wondering if this could ever be extended for Feeds?

    Thread Starter Eric Mann

    (@ericmann)

    I’ve decided to take this one step further. Hacking the WP source is fine if you want to do it every time you upgrade … but I’m a bit lazy. So instead I built a plugin that does this all for me!

    What you do is install the plugin, build a new page (https://blog.com/premium) or something along those lines, and place the shortcode ‘[reglevel]’ on the new page. When prospective users go to the new page, they are redirected to the registration screen and WP changes the user level to whatever you have set up in the Options»RegLevels settings.

    You can download the plugin here: https://www.jumping-duck.com/wordpress/. I’m still working to get it hosted on the WP site.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Premium Content’ is closed to new replies.