• Resolved Ramzii

    (@ramzii)


    After some digging I found this code to enable custom post type blocking:

    add_filter( 'wpmem_settings', 'my_cpt_settings' );
    function my_cpt_settings( $settings ) {
    
    	/** Complete this block for any CPT **/
    
    	// Set to the name of your custom post type
    	$cpt_slug = "acme_product";
    
    	// Block by default (1=block, 0=unblock)
    	$settings['block'][ $cpt_slug ] = 1;
    
    	// Show excerpts (1=yes, 0=no)
    	$settings['show_excerpt'][ $cpt_slug ] = 0;
    
    	// Show login form (1=yes, 0=no)
    	$settings['show_login'][ $cpt_slug ] = 1;
    
    	// Show registration form (1=yes, 0=no)
    	$settings['show_reg'][ $cpt_slug ] = 1;
    
    	/** End CPT Block **/
    
    	// Return extra settings at the end.
    	return $settings;
    }

    Unfortunatly it doe not block the whole part of the page. I just got into this plugin, but could someone tell me how to block a specific div with this class “show-coupon”.

    Thanks!

    https://wordpress.org/plugins/wp-members/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    The code snippet you referenced is unnecessary as Custom Post Type support is added natively to the plugin in version 3.0.9. So everything that snippet does is now incorporated into the plugin’s main options tab. (Based on the rest of your question though, I’m not sure that this has anything to do with your question.)

    A div class is CSS and that’s not the premise the plugin works on in handling content. The plugin generally blocks what is in the WordPress $content variable for singular posts and pages. That means the content that would be part of the main content area in the post editor.

    If you have a smaller piece of content to block, you can use the [wpmem_logged_in] shortcode to wrap it like so:

    [wpmem_logged_in]This only shows to logged in users[/wpmem_logged_in]

    Thread Starter Ramzii

    (@ramzii)

    Hey thanks for the quick reply! Unfortunately it must be a bug then. I indeed did see the CPT’s in the native admin section of the plugin. But when added and blocked by default it still showed up. But after adding the aforementioned code it did get blocked.

    Hmm the part of the template is getting generated outsite the $content i think.
    Its a div inside the sidebar area.

    How about using your code with the do_shortcode php tag inside a php template to block out certain parts of the template?

    Thanks!

    Plugin Author Chad Butler

    (@cbutlerjr)

    Unfortunately it must be a bug then. I indeed did see the CPT’s in the native admin section of the plugin. But when added and blocked by default it still showed up. But after adding the aforementioned code it did get blocked.

    Not all CPTs will be able to work this way. As you mentioned, if the content is outside of the $content variable, it won’t be handled in the same way.

    If it’s in the sidebar, you can use the [wpmem_logged_in] shortcode to show/hide that content, but your sidebar will need to be able to execute shortcodes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Use css to block one part of custom post type page?’ is closed to new replies.