Skip Navigation

[Resolved] Memberpress affecting custom view

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to bypass the MemberPress plugin restricted post rules with content template

Solution:
You should dispaly [wpv-post-body] shortcode with attribute "suppress_filters" set to "true" to bypass the custom shortcodes and hooks.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/memberpress-affecting-custom-view/page/2/#post-724337

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 21 replies, has 3 voices.

Last updated by Robert 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#702054

That doesn't make sense to me, because this behaviour is not happening within a normal category archive.

For example:
hidden link

The first article in the standard archive loop (Monthly Superannuation Returns Performance Reckoner (for 5 investment options)) is protected.

You can see that here: hidden link

But WordPress shows the elements I want to show through Toolset - the Title and Thumbnail

Is there a way that Toolset can show this view in the same way that WordPress archives show it?

#713810

Hello,

Minesh isn't available currently, you will get the answer soon when he is back in tomorrow.

#722848

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I can tell you simple thing to test. Create a single.php for any specific post type and for that post type try to display restricted post - you will see the login form - that is set to display when unauthorized person try to access restricted post from memberpress plugin.

I tested this and MemberPress is hijacking the normal standard WP_Query. I do not have any way to offer here, as per our support policy, we are not bound to debug the third party plugin code.

The only way I can see you can display the post content is using custom shortcode. So here is the workaround:

Add following code to your current theme's functions.php file:

add_shortcode('display_content', function(){
  
	global $post;
	$content = $post->post_content;
return $content;
	
    
} );

And in your view's loop output instead of using [wpv-post-body] shortcode - use this custom shortcode:

[display_content]
#723549

Hi Minesh - Thanks for your suggestion, but that workaround doesn't work for me.

The result of that code is that it replaces the Title and Thumbnail with the body of the entire post. You can see for yourself here: hidden link

Please note this was the code I had in the Loop Output Editor for that View

 [wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
   <wpv-loop>
      <div class="three">[wpv-post-body view_template="Latest News Sidebar - single post"]
  </div></wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-posts-found][wpml-string context="wpv-views"]<strong>No posts found</strong>[/wpml-string][/wpv-no-posts-found]
[wpv-layout-end]

Note that it was calling a content template so this is what I following your suggestion

 [wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
   <wpv-loop>
      <div class="three">[display_content view_template="Latest News Sidebar - single post"]
  </div></wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-posts-found][wpml-string context="wpv-views"]<strong>No posts found</strong>[/wpml-string][/wpv-no-posts-found]
[wpv-layout-end]

Cheers, Rob

#723620

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you need to keep your image fields.

You should restructure your loop output with your needed fields - add those fields.

<wpv-loop>
      <div class="three">
-- add your image field
-- add your title field ...etc.. etc..
[display_content]

  </div></wpv-loop>
#723684

After a bit of trial and error, I worked out that I do not need the [display_content]. That was displaying the post content, which is not what I wanted.

For your records this is what I changed it to to make it work (in the View > Loop Output Editor

 [wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
   <wpv-loop>
      <div class="three"><li class="media">
	<a class="pull-left thumbnail" href="[wpv-post-url]">[wpv-post-featured-image]</a>
	<div class="media-body">
		<h3 class="media-heading"><a href="[wpv-post-url]">[wpv-post-title output="sanitize"]</a></h3>
</div>
  </div></wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-posts-found][wpml-string context="wpv-views"]<strong>No posts found</strong>[/wpml-string][/wpv-no-posts-found]
[wpv-layout-end]

I also did not need what you suggested to add to functions.

However, this means that if I ever need to change that layout I have to change it on every View (we have over 50) one by one, rather than only once in the Content Template.

Is there a way to do this where I can use a Content Template?

#724337

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please try following shortcode:

[wpv-post-body view_template="Latest News Sidebar - single post" suppress_filters="true"]

Does this help?

#725611

Thanks Minesh - That worked and was all I needed.

Cheers, Rob