• 19-08-2019, 16:26:05
    #1
    Merhaba,
    Site üzerinden premium üyelik alan kullanıcılara site reklamsız gösterilecek. Bu nasıl yapılabilir?
  • 19-08-2019, 16:35:10
    #2
    Üyeliği Wordpress üzerinde mi satıyorsunuz
  • 19-08-2019, 16:36:43
    #3
    Yazılım nedir hocam? Xenforoda kolayca yapılabiliyor
  • 19-08-2019, 16:46:07
    #4
    add_action( 'user_register', 'add_premium_field', 10, 1 );
    
        function add_premium_field( $user_id ) {
            add_user_meta($user_id, 'premium_user', 0);
        }
    
        add_action( 'show_user_profile', 'premium_user_profile_fields' );
        add_action( 'edit_user_profile', 'premium_user_profile_fields' );
    
        function premium_user_profile_fields( $user ) { 
            if($user->ID == 1):
            ?>
            <h3><?php _e("Premium Kullanıcı Alanı", "theme_name"); ?></h3>
    
            <table class="form-table">
            <tr>
                <th><label for="premium_user"><?php _e("Premium User"); ?></label></th>
                <td>
                    <input type="text" name="premium_user" id="premium_user" value="<?php echo esc_attr( get_the_author_meta( 'premium_user', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description"><?php _e("Premium aktif etmek için 1, pasif yapmak için 0 yazın"); ?></span>
                </td>
            </tr>
        <?php 
        endif;  
        }
        add_action( 'personal_options_update', 'save_premium_user_profile_fields' );
        add_action( 'edit_user_profile_update', 'save_premium_user_profile_fields' );
        
        function save_premium_user_profile_fields( $user_id ) {
            if ( !current_user_can( 'edit_user', $user_id ) ) { 
                return false; 
            }
            if($user_id == 1){
                update_user_meta( $user_id, 'premium_user', $_POST['premium_user'] );
            }
            
        }
    
        function premium_ads_css() {
            $checkPremium = get_user_meta( $user_id, 'premium_user', true );
            if($checkPremium == 1):
            ?>
                <style>
                    .adsContainer{
                        display:none;
                    }
                </style>
            <?php
            endif;
        }
        add_action('wp_head', 'premium_ads_css');
    .adsContainer kısmındaki cssi siz reklam alanlarınızın classlarını yazarak gizletebilirsiniz. temanızın functions.php dosyasına eklenecek kodlar.
  • 19-08-2019, 18:10:47
    #5
    redevelop adlı üyeden alıntı: mesajı görüntüle
    Üyeliği Wordpress üzerinde mi satıyorsunuz
    Şu anda satış yapmıyorum. Sadece bilgi için yazdım.



    Ecancan adlı üyeden alıntı: mesajı görüntüle
    add_action( 'user_register', 'add_premium_field', 10, 1 );
    
        function add_premium_field( $user_id ) {
            add_user_meta($user_id, 'premium_user', 0);
        }
    
        add_action( 'show_user_profile', 'premium_user_profile_fields' );
        add_action( 'edit_user_profile', 'premium_user_profile_fields' );
    
        function premium_user_profile_fields( $user ) {
            if($user->ID == 1):
            ?>
            <h3><?php _e("Premium Kullanıcı Alanı", "theme_name"); ?></h3>
    
            <table class="form-table">
            <tr>
                <th><label for="premium_user"><?php _e("Premium User"); ?></label></th>
                <td>
                    <input type="text" name="premium_user" id="premium_user" value="<?php echo esc_attr( get_the_author_meta( 'premium_user', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description"><?php _e("Premium aktif etmek için 1, pasif yapmak için 0 yazın"); ?></span>
                </td>
            </tr>
        <?php
        endif;  
        }
        add_action( 'personal_options_update', 'save_premium_user_profile_fields' );
        add_action( 'edit_user_profile_update', 'save_premium_user_profile_fields' );
        
        function save_premium_user_profile_fields( $user_id ) {
            if ( !current_user_can( 'edit_user', $user_id ) ) {
                return false;
            }
            if($user_id == 1){
                update_user_meta( $user_id, 'premium_user', $_POST['premium_user'] );
            }
            
        }
    
        function premium_ads_css() {
            $checkPremium = get_user_meta( $user_id, 'premium_user', true );
            if($checkPremium == 1):
            ?>
                <style>
                    .adsContainer{
                        display:none;
                    }
                </style>
            <?php
            endif;
        }
        add_action('wp_head', 'premium_ads_css');
    .adsContainer kısmındaki cssi siz reklam alanlarınızın classlarını yazarak gizletebilirsiniz. temanızın functions.php dosyasına eklenecek kodlar.
    Hocam, classları düzenleyemedim. Yardımcı olabilir misiniz?
  • 19-08-2019, 21:05:25
    #6
    vidtekno adlı üyeden alıntı: mesajı görüntüle
    Şu anda satış yapmıyorum. Sadece bilgi için yazdım.




    Hocam, classları düzenleyemedim. Yardımcı olabilir misiniz?
    site adresinizi pm ile iletin. Reklam alanlarınızın konumlarını tespit ettikten sonra son halini ekleyeyim.
  • 19-08-2019, 21:06:47
    #7
    Ecancan adlı üyeden alıntı: mesajı görüntüle
    site adresinizi pm ile iletin. Reklam alanlarınızın konumlarını tespit ettikten sonra son halini ekleyeyim.
    P.M. Gönderildi



    @Ecancan; çok yardımcı oldu. Teşekkürler.
  • 19-08-2019, 22:43:08
    #8
    Kodun son hali aşaağıdır. Bizzat hedef sitede test edilmiştir. Premium üyelik ayrıcağılı yapmak isteyen arkadaşlar için kullanışlı ve basit bir sistemdir.

    add_action( 'user_register', 'add_premium_field', 10, 1 );
     
        function add_premium_field( $user_id ) {
            add_user_meta($user_id, 'premium_user', 0);
        }
     
        add_action( 'show_user_profile', 'premium_user_profile_fields' );
        add_action( 'edit_user_profile', 'premium_user_profile_fields' );
     
        function premium_user_profile_fields( $user ) { 
            $user_meta = get_userdata(get_current_user_id());
            $user_roles = $user_meta->roles;
    
            if ( in_array( 'administrator', $user_roles, true ) ) :
            ?>
            <h3><?php _e("Premium Kullanıcı Alanı", "theme_name"); ?></h3>
     
            <table class="form-table">
            <tr>
                <th><label for="premium_user"><?php _e("Premium User"); ?></label></th>
                <td>
                    <input type="text" name="premium_user" id="premium_user" value="<?php echo esc_attr( get_the_author_meta( 'premium_user', $user->ID ) ); ?>" class="regular-text" /><br />
                    <span class="description"><?php _e("Premium aktif etmek için 1, pasif yapmak için 0 yazın"); ?></span>
                </td>
            </tr>
        <?php 
        endif;  
        }
        add_action( 'personal_options_update', 'save_premium_user_profile_fields' );
        add_action( 'edit_user_profile_update', 'save_premium_user_profile_fields' );
         
        function save_premium_user_profile_fields( $user_id ) {
            if ( !current_user_can( 'edit_user', $user_id ) ) { 
                return false; 
            }
            $user_meta = get_userdata(get_current_user_id());
            $user_roles = $user_meta->roles;
    
            if ( in_array( 'administrator', $user_roles, true ) ) {
                update_user_meta( $user_id, 'premium_user', $_POST['premium_user'] );
            
            }
             
        }
     
        function premium_ads_css() {
            $checkPremium = get_user_meta( get_current_user_id(), 'premium_user', true );
            if($checkPremium == 1):
            ?>
                <script type="text/javascript">
                    $(document).ready(function(){
                      $("ins.adsbygoogle").hide();
                    });
                </script>
    
            <?php
            endif;
        }
        add_action( 'wp_footer', 'premium_ads_css', 100 );