• 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 » Blocking Content from Builder Plugins

Blocking Content from Builder Plugins

Chad Butler · Jun 27, 2014 ·

WP-Members has always focused on content contained in the WordPress $content variable. More recently, the popularity of builder plugins such as Page Builder by SiteOrigin or Elegant Builder from Elegant Themes has raised the issue of blocking content that is not necessarily stored in the same manner.

Note: as of version 3.0.4, the priority of WP-Members filter hooked to the_content has been changed to accommodate builder plugins. The priority is now 99, so unless another plugin sets its priority at 100 or higher, WP-Members will come after it (which is what you want). I’ve left the information in this post intact as it may be useful for some applications, but for most users, it will be unnecessary.

The post focuses on the general approach to blocking content from these types of plugins and includes code snippets you can use for the two plugins mentioned above.  

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 filters, get_{$metatype}_metadata, is_user_logged_in, page-builder, tips

Welcome to RocketGeek Interactive › Forums › Blocking Content from Builder Plugins

Tagged: filters, get_{$metatype}_metadata, is_user_logged_in, page-builder, tips

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

      WP-Members has always focused on content contained in the WordPress $content variable. More recently, the popularity of builder plugins such as Page B
      [See the full post at: Blocking Content from Builder Plugins]

    • October 7, 2014 at 10:28 am #6041
      filltrexx
      Participant

      Hello, I am using this theme and their content builder: http://themeforest.net/item/one-the-creative-multipurpose-portfolio-theme/7624003
      When I block a page, the login/register fields appear in each content builder “block”/section (~15 times). Can you suggest a work around for this? Thank you!

      • October 7, 2014 at 11:09 am #6045
        Chad Butler
        Keymaster

        There must be something in that theme’s process that runs the WP function the_content multiple times. To know what would cause that, I’d need to look at the theme directly so I could see what they are doing – basically I’d need you to send me a copy of the theme for review. Send me a message through the contact form and I’ll get you the info.

    • June 12, 2015 at 4:04 am #8084
      pawi
      Participant

      This only works if the whole content is blocked,
      however i only block certain pages. With this patch all pages lack
      the content for logged out users.

      Is there any way to verify if the current page actually is blocked
      before stripping the builder content?

      • June 12, 2015 at 2:03 pm #8088
        Chad Butler
        Keymaster

        You are correct – the logic as originally posted is indiscriminate as to whether the content is actually set as blocked (either by default or at the post/page level). It is just looking to see if the user is logged in or not.

        It should probably be amended to check not just the user’s login status, but also the content’s block status – should it be blocked or not.

        I think that the logical test could just be changed from this:

        if( ! is_user_logged_in() ) {

        to this:

        if( ! is_user_logged_in() && wpmem_block() ) {

        • June 20, 2016 at 10:12 am #10559
          jasonhunterdesign
          Participant

          if( ! is_user_logged_in() && wpmem_block() ) {

          This is not working for me. It’s whiting out the whole page actually. Any further suggestions since this was posted almost a year ago?

          • June 20, 2016 at 10:31 am #10563
            Chad Butler
            Keymaster

            Yes, this is a little dated. As noted in the post, most of this no longer applies as the plugin has been updated to accommodate as much of this by default as possible.

            Version 3.0.4 of the plugin moved the priority of the function it runs to filter the_content to a later point which puts it after the most common builder plugins. Several of the builder plugins I looked at ran their filters on the_content at a priority of 20 or 30. The problem was that because WP-Members ran on the_content earlier than that, the builder plugin would be coming in after and basically undoing what WP-Members was doing. So WP-Members now runs do_securify() at a priority of 99 so that it comes after these and not before.

            That certainly doesn’t mean you can’t run into problems. These builders are fairly complex applications so there can be all kind of unforeseen issues in providing compatibility.

            That being said, most things should be covered by the move to a later filter point.

            The wpmem_block() function actually has been replaced by both a method in the (newer) WP_Members object class and a wrapper for calling it in the API. wpmem_block() was deprecated in the most recent release, and while it will still function, wpmem_is_blocked() is the function that should be used.

            My guess that whiteing out the page is not the result of this, however. If you don’t have an error message it’s hard to say specifically, but my guess would be that whereever this is being called the function may not be available (i.e. if you are calling it before it’s loaded, that would be a problem).

            Since the need for this is somewhat obsolete, open a message in the contact form or a new thread in the support forum and let me know how this is being called and I’ll take a look at what you’ve got.

    • January 4, 2016 at 8:54 am #9247
      pdsweb
      Participant

      What about Visual Composer?

      • January 4, 2016 at 9:29 am #9248
        Chad Butler
        Keymaster

        Actually, this information is a little bit dated and I’ll update the post accordingly. Version 3.0.4 changed the priority of the_content filter to come later in the process to accommodate these builder plugins. The priority is now 99, so unless a builder plugin hooks to the_content with a priority of 100 or higher, WP-Members should handle it.

    • March 11, 2016 at 2:42 am #9746
      verrado
      Participant

      Hello Chad –

      I’m currently experiencing the issue of pages not being blocked with a site that is using Advanced Custom Fields WP Plugin.

      Is there some way to wrap all of the content fields at a template level so that the “Block this page” check box works in edit mode?

      Example, if there were a content area like this:

      <?php the_field(‘first_content_block’); ?>
      <?php the_field(‘second_content_block’); ?>
      <?php the_field(‘third_content_block’); ?>
      <?php the_field(‘fourth_content_block’); ?>

      Thanks,

      Matt

      • March 11, 2016 at 8:43 am #9750
        Chad Butler
        Keymaster

        Hi Matt,

        I might need some context on how you are using ACF. Generally ACF is different from builder plugins, although it sounds like you are using it as one?

        I would start with the Advanced Options extension. When ACF is installed and activated, the extension has two extra settings for handling ACF. You can either dump all ACF fields if the user is not logged in or only if the user is not logged in and the content is marked as blocked.

        That in itself might handle what you are looking for.

  • 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