Ziyaretçilere kategori kapatıp Üyelere kategori açma
5
●231
- 26-07-2017, 01:25:47sanırım demek istediğin üye olmayanlar belirli kategorileri görmesini istemiyorsun.
Bu sayfada istediğin şekilde kod paylaşılmış.
add_filter('template_include', 'restict_by_category'); function check_user() { $user = wp_get_current_user(); if ( ! $user->ID || in_array('subscriber', $user->roles) ) { // user is not logged or is a subscriber return false; } return true; } function restict_by_category( $template ) { if ( ! is_main_query() ) return $template; // only affect main query. $allow = true; $private_categories = array('reserved', 'personal'); // categories subscribers cannot see if ( is_single() ) { $cats = wp_get_object_terms( get_queried_object()->ID, 'category', array('fields' => 'slugs') ); // get the categories associated to the required post if ( array_intersect( $private_categories, $cats ) ) { // post has a reserved category, let's check user $allow = check_user(); } } elseif ( is_tax('category', $private_categories) ) { // the archive for one of private categories is required, let's check user $allow = check_user(); } // if allowed include the required template, otherwise include the 'not-allowed' one return $allow ? $template : get_template_directory() . '/not-allowed.php'; }
veya
https://wordpress.org/plugins/restrict-categories/ bu eklenti ile yapabilirsin. - 26-07-2017, 02:18:45sakarya adlı üyeden alıntı: mesajı görüntüleSalihweb adlı üyeden alıntı: mesajı görüntüle
Hocam belirlediğim bir kategori telif hakkından dolayı sadece üye olanlar görebilmeli, ama tema özel yazılım bir tema salih hocam bana yardımcı olabilirmisiniz özel dizi alanı kategori olarak geçmiyor sanırım nasıl yapabilirim ?