Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Andrew

    (@turdin)

    I had to make this on the code to got it working:

    foreach(array(__('Posts') => 'post',__('Downloads') => 'dlm_download') as $k => $post_type){
    	$p->add_field(array(
    		'label'   => 'Enable on  '.$k,
    		'std'     => true,
    		'id'      => 'posttypes]['.$post_type,
    		'type'    => 'checkbox',
    		'section' => $setting2,
    		)
    	);
    }

    And one more thing, translation is not working. But great plugin, saved my life ??

    where did you add this code please?

    Thread Starter Andrew

    (@turdin)

    config/main_plugin_fields.php
    after

    foreach(array(__('Posts') => 'post',__('Pages') => 'page') as $k => $post_type){
    	$p->add_field(array(
    		'label'   => 'Enable on  '.$k,
    		'std'     => true,
    		'id'      => 'posttypes]['.$post_type,
    		'type'    => 'checkbox',
    		'section' => $setting2,
    		)
    	);
    }

    It only work to “dlm_download” custom post type, i have to add every custom post type in my site to get it working, not a fix, just a temporary workaround

    Thanks

    Great solution! Thank you!

    Plugin Author Bainternet

    (@bainternet)

    A better solution would be to use the provided filters and hooks in the plugin (always avoid editing files that get updates)

    //using a filter hook
    add_filter('USC_allowed_post_types','usc_filter_post_types');
    function usc_filter_post_types($types){
    	//to add a custom post type
    	$types[] = 'MY_CUSTOM_POST_TYPE_NAME';
    
    	//to remove a post type
    	if(($key = array_search('post', $types)) !== false) {
        	    unset($types[$key]);
    	}
    }

    Hi,

    I used this hook but unble to see meta box on my custom post type. can you please give a solution. I am using wordpress 4.6.1.

    Thanks

    Danish Jamshed

    Never mind admin. I was not returning it back.

    here is the solution

    //using a filter hook
    add_filter(‘USC_allowed_post_types’,’usc_filter_post_types’);
    function usc_filter_post_types($types){
    //to add a custom post type
    $types[] = ‘MY_CUSTOM_POST_TYPE_NAME’;
    return $types;
    }

    Sorry i add this latest code in my function.php but i do not see the meta box in my custom post “listing” What’s wrong?
    Thanks

    Hello,
    I make your code work for Woocommerce Products with this :

    add_filter('USC_allowed_post_types','usc_filter_post_types');
    function usc_filter_post_types($types){
    //to add a custom post type
    $types[] = 'product';
    return $types;
    }

    The meta box i displayed on products editing pages now.
    But the options I choose in this meta box are not applied. I want some products to be displayed only for certain registered customers. So I check the boxes for these particular users.
    When I make some test on the front side, every users can see these products.
    Your plugin works for pages and post on my site. But not for products.
    Is that normal?

    Hello,

    Sorry I am a novice to wordpress, and am slightly confused by where to put the code. I have a website that sells a product to wholesale customers. Using the plugin we want our customers to be able to login to their own accounts, and see the private store. I understand that this plugin allows for pages to be made private for whole sale customers, but does not work on woocommerce stores. Does the code above change this, and where specifically do I put the code above?

    Thank you.

    Thank you for this plugin.. It saved my project.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Use with custom post type’ is closed to new replies.