Üyeliği Wordpress üzerinde mi satıyorsunuz
Şu anda satış yapmıyorum. Sadece bilgi için yazdım.
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?