Jump to content


This topic is now archived and is closed to further replies.


DMS is filtering content when it shouldn't be

Recommended Posts


I am using the new WooCommerce Memberships plugin. http://www.woothemes.com/products/woocommerce-memberships/

This plugin filters my selected content and only lets my paying members view it. For non-members, it's supposed to replace the content with a message telling them that they need to be a member in order to view the content. Using DMS, this notification message does not appear. There is simply no content at all. When I switch to a default wordpress theme like Twenty Thirteen, the notification message appears as it should. Here is part of the membership plugin code that deals with displaying the notification text:

if ( ! in_array( $post->ID, $this->content_restriction_applied ) ) { echo 'You must be a member to view this content'; }

Basically this code is saying is that if the content is not already filtered, echo the notification. If I remove the ! at the beginning of the code, the notification message appears as it should, however it negatively affects other issues, such as the "Latest Posts" widget in the Columnizer section. I emailed WooCommerce about the issue, and they said that the issue is with DMS. Here is what they said:


"I tested locally with the DMS theme and experienced the same result as you did. Unfortunately, we are not able to guarantee compatibility with 3rd party themes or plugins, though we make every effort to build extensions that adhere to best practices.

To answer your question, the ! means not - or rather if the condition that follows evaluates to false - the PHP function in_array will check to see if the current post id is in the array called content_restriction_applied - so, basically, that conditional statement says: "If this post has not been filtered already, filter it now" In my testing, if I remove the ! then yes, the restricted post content works as expected, but I can see right away, in the default configuration of DMS that the 'Latest Posts' widget in the footer has the same content applied to it as the post does. I'm guessing this is undesirable and is an indicator that you can expect to have problems if you remove the ! from the conditional statement.

To reiterate, the DMS theme is filtering content when it should not be - that is what is causing this issue with Memberships. I would recommend opening a support request with the theme authors. Something like this:

Subject: filtering the_content produces unexpected results

To reproduce:


  • Fresh install of WordPress
  • No plugins active
  • In addition to the 'Hello World' post that exists in the default installation, create two posts, each with unique content
  • assume that the 'Hello World' post has an id of 1 (adjust below code as necessary if not)
  • In dms/functions.php add the following code
add_filter( 'the_content', 'my_content_filter_callback' );

function my_content_filter_callback( $content ) {
    if ( 1 == get_the_ID() ) {
        $content = 'This is the filtered content';
    return $content;
  • Visit the single post page for 'Hello World'

Expected result: The "Recent Posts" in the footer retain their unique content (or excerpt, as appropriate)

Actual result: Each of the "Recent Posts" outputs the filtered content even though their id does not match the condition for filtering

see screen shot: http://cld.wthms.co/199R8/3ITmh4ib


Please help!!!


Share this post

Link to post
Share on other sites

Two and a half weeks and not even one rely? what happened to the priority support I am paying for as a club member?

Share this post

Link to post
Share on other sites

Hi Chris,

Not sure what happened here, your post wasn't in the unanswered posts que? Will need to speak to Simon about that.

I am unable to test this due to the plugin being a premium one. However, what section are you using to display your content the default WP-Content/PostLoop section? If so, have you tried legacy mode?

Please search our forums, before posting!

Share this post

Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please?