• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Filters » Block Posts After a Set Number of Page Views

Block Posts After a Set Number of Page Views

Chad Butler · Jun 7, 2014 ·

On occasion, the question of how to only prompt to login after a specific number of page views or an amount of time has passed. While there is no real fool proof way to implement this type of process, there are some ways you can implement it if this is right for you.

This demonstration will focus on requiring a user to login on blocked content after a set number of pages have been viewed on the site.  

This article is only available to WP-Members Support Subscribers. If you have an existing subscription, please login below. If you do not have a current support subscription, you can purchase a support subscription here.

Already a Member? Log In Here
   
Forgot password? Click here to reset

To gain full access to WP-Members premium content, a current support subscription is required. You can purchase an annual support subscription for as little as $59, which provides you with access to priority support, a customer support forum, access to code snippets, and more.

Why wait? Choose your subscription option here.

[
Why join?]

Filters, Tips and Tricks wpmem_block

Welcome to RocketGeek Interactive › Forums › Block Posts After a Set Number of Page Views

Tagged: wpmem_block

  • This topic has 7 replies, 2 voices, and was last updated 6 years, 4 months ago by Chad Butler.
Viewing 4 reply threads
  • Author
    Posts
    • June 7, 2014 at 10:01 pm #5061
      Chad Butler
      Keymaster

      On occasion, the question of how to only prompt to login after a specific number of page views or an amount of time has passed. While there is no real
      [See the full post at: Block Posts After a Set Number of Page Views]

    • September 10, 2014 at 7:37 am #5831
      jsowers897
      Participant

      Hi,

      I like this function, but is there a way to make it so that it only counts pages that are set to be blocked, and does not count pages set to unblocked? It seems to be counting/blocking all pages after the count of 5 even if that page is set to unblocked, and then blocks the unblocked page as well. Does that makes sense? I want non-members to be able to view 5 blocked pages, then after 5 they will be blocked, but leave the unblocked pages as unblocked.

      Thanks,

      James

      • September 11, 2014 at 11:20 am #5842
        Chad Butler
        Keymaster

        Hi James,

        So after working on this question a little bit, I put together a modified version of the original code snippet. See the notes and code in the original post above. I think this is an improvement over the original. Thanks for the suggestion!

    • September 12, 2014 at 1:02 am #5847
      jsowers897
      Participant

      Awesome! Thanks! So the last part of the notes, what will need to be done? Or will you provide an updated function? Not really sure what you were saying, i’m not 100% code-speak literate :).

    • September 12, 2014 at 1:14 am #5848
      jsowers897
      Participant

      Hmmm for me it’s blocking pages set to unblocked after the 5 views. I have it set to block all pages by default, then unblocked certain pages, like the home page, etc. But after the 5 views every page is blocked.

      • September 12, 2014 at 3:37 pm #5855
        Chad Butler
        Keymaster

        OK – I added some additional logic to the last function – the one that is the filter function for wpmem_block. Try that and let me know how it works out.

    • September 14, 2014 at 6:32 am #5863
      jsowers897
      Participant

      I have it set to Block all Pages (posts are not blocked), and then have certain pages set to unblocked. With the newest code, it’s not allowing the 5 views, it’s just blocking the blocked pages. I deleted the cookie and cleared the cache, same result 🙁

      • September 14, 2014 at 3:34 pm #5866
        Chad Butler
        Keymaster

        I tested with the same setup as you described (blocking pages by default, unblocking specific pages). I’ll review it and see.

  • Author
    Posts
Viewing 4 reply threads
  • You must be logged in to reply to this topic.
Log In

Ready to get started?

Join Today!

© 2021 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Refund Policy