mamadspeed 27 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 با سلام خدمت دوستان می خواستم بدونم چطوری میشه فیلدی به شناسنامه کاربر اضافه کرد که فقط توسط ادمین قابل تغییر باشه با تشکر نقل قول لینک به ارسال
imanfakhar 26231 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 اگر قراره فقط ادمین توش دست ببره که دیگه چه اصراری به ساخت فیلد با استفاده از تابع add_user_meta( $user_ID, $key ,$value);متا را بسازید و با استفاده از تابع update_user_meta( $user_ID, $key ,$value);به روزش کنید و با تابع get_the_author_meta( $key, $user_ID )نمایشش بدید 2 نقل قول لینک به ارسال
mamadspeed 27 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 (ویرایش شده) با تشکر میشه برام توضیح بدید چطوری میشه تو شناسنامه هر کاربر نمایش بدم مثلا میخوام ادرس محل زندگی کاربر به صورت دستی واردکنم و توی شناسنامش نشون بده اما نتونه تغییر بده ویرایش شده دی 92 توسط mamadspeed نقل قول لینک به ارسال
mamadspeed 27 ارسال شده در دی 92 مالک گزارش بازنشر ارسال شده در دی 92 با عرض معذرت از دوستان کد زیر رو پیدا کردم اما بلد نیستم فقط کاری کنم که ادمین بتونه تغییر بده با تشکر اگه راهنمایی کنید ممنون میشمfunction fb_add_custom_user_profile_fields( $user ) {?><h3><?php _e('Extra Profile Information', 'your_textdomain'); ?></h3><table class="form-table"> <tr> <th> <label for="address"><?php _e('Address', 'your_textdomain'); ?> </label></th> <td> <input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br /> <span class="description"><?php _e('Please enter your address.', 'your_textdomain'); ?></span> </td> </tr></table><?php }function fb_save_custom_user_profile_fields( $user_id ) {if ( !current_user_can( 'edit_user', $user_id ) ) return FALSE;update_usermeta( $user_id, 'address', $_POST['address'] );}add_action( 'show_user_profile', 'fb_add_custom_user_profile_fields' );add_action( 'edit_user_profile', 'fb_add_custom_user_profile_fields' );add_action( 'personal_options_update', 'fb_save_custom_user_profile_fields' );add_action( 'edit_user_profile_update', 'fb_save_custom_user_profile_fields' ) نقل قول لینک به ارسال
Parsa 23463 ارسال شده در دی 92 گزارش بازنشر ارسال شده در دی 92 با این افزونه میتوانیدhttp://wordpress.org/plugins/extra-user-fields/روش دستی<?phpif(current_user_can("level_10")){add_action( 'show_user_profile', 'extra_user_profile_fields' );add_action( 'edit_user_profile', 'extra_user_profile_fields' );add_action( 'personal_options_update', 'save_extra_user_profile_fields' );add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );}function extra_user_profile_fields( $user ) { ?><h3><?php _e("Extra profile information", "blank"); ?></h3><table class="form-table"><tr><th><label for="address"><?php _e("Address"); ?></label></th><td><input type="text" name="address" id="address" value="<?php echo esc_attr( get_the_author_meta( 'address', $user->ID ) ); ?>" class="regular-text" /><br /><span class="description"><?php _e("Please enter your address."); ?></span></td></tr><tr><th><label for="city"><?php _e("City"); ?></label></th><td><input type="text" name="city" id="city" value="<?php echo esc_attr( get_the_author_meta( 'city', $user->ID ) ); ?>" class="regular-text" /><br /><span class="description"><?php _e("Please enter your city."); ?></span></td></tr><tr><th><label for="province"><?php _e("Province"); ?></label></th><td><input type="text" name="province" id="province" value="<?php echo esc_attr( get_the_author_meta( 'province', $user->ID ) ); ?>" class="regular-text" /><br /><span class="description"><?php _e("Please enter your province."); ?></span></td></tr><tr><th><label for="postalcode"><?php _e("Postal Code"); ?></label></th><td><input type="text" name="postalcode" id="postalcode" value="<?php echo esc_attr( get_the_author_meta( 'postalcode', $user->ID ) ); ?>" class="regular-text" /><br /><span class="description"><?php _e("Please enter your postal code."); ?></span></td></tr></table><?php }function save_extra_user_profile_fields( $user_id ) {if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }update_user_meta( $user_id, 'address', $_POST['address'] );update_user_meta( $user_id, 'city', $_POST['city'] );update_user_meta( $user_id, 'province', $_POST['province'] );update_user_meta( $user_id, 'postalcode', $_POST['postalcode'] );}?>http://bavotasan.com/2009/adding-extra-fields-to-the-wordpress-user-profile/در کد خودتوناین خط را تغییر دهیدif ( !current_user_can( 'level_10', $user_id ) ) return FALSE; 3 نقل قول لینک به ارسال
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .