Wp'de yorum yazana içerik gözüksün ??
2
●77
- 11-11-2014, 11:48:26Hocam sadece indirme linkini gizlemek için, sayfanızın yapısını görmemiz lazım. Ben tamamen içeriği şu şekilde gizlettim:
Temanızdaki functions.php'nin en altına şu fonksiyonu ekleyin:
# Kullanıcı belirtilen post'a yorum yapmışmı kontrol et function yorumYaptimi($post_id){ global $wpdb; if(is_user_logged_in()){ $user_id = get_current_user_id(); return $wpdb->get_var("SELECT comment_ID FROM wp_comments WHERE comment_post_ID = $post_id AND user_id = $user_id"); }else { $user_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP); if(!$user_ip) return false; return $wpdb->get_var("SELECT comment_ID FROM wp_comments WHERE comment_post_ID = $post_id AND user_id = 0 AND comment_author_IP = '$user_ip'"); } }Daha sonra temanızın single.php'sinde the_content() yada get_the_content() fonksiyonlarını bulup şöyle değiştirin
if( yorumYaptimi(get_the_ID()) ){ the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfourteen' ) ); // burası sizin eski the_content fonksiyonunuz }else{ echo "İçeriği görmek için yorum yapmalısınız."; }Giriş yapmış kullanıcıları ID'sine göre, giriş yapmayan kullanıcıları IP'sine göre kontrol ediyor.