۲ اسماعیل آبابائی
فیلدهای شبکه اجتماعی تو بخش کاربران نیست.
بهنام مرادی حل شده توسط بهنام مرادی

با سلام فیلد شبکه‌های اجتماعی را توی بخش مدیریت کاربران نداریم .چطور مثل استاد اون‌ها رو داشته باشیم؟ 

با سلام 

خود وردپرس در بخش کاربران دارای شبکه‌های اجتماعی نیست، ولی پلاگین‌های مختلف ممکن است به این بخش پروفایل‌های اجتماعی را اضافه کنند.

موفق باشید

بهترین پاسخ
بهنام مرادی ۱۱ بهمن ۱۴۰۲، ۱۸:۲۶

سلام

برای دوستانی که مشکل دارند، از Setting API استفاده کنند. نمونه کد قرار میدم:

 

add_action('show_user_profile', 'add_social_profiles_fields');
add_action('edit_user_profile', 'add_social_profiles_fields');
function add_social_profiles_fields($user)
{
?>
    <h3>شبکه‌های اجتماعی</h3>
    <table class="form-table">
        <tr>
            <th><label for="instagram">اینستاگرام</label></th>
            <td>
                <input type="text" name="instagram" id="instagram"
                    value="<?php echo esc_attr(get_the_author_meta('instagram', $user->ID)); ?>"
                    class="regular-text" /><br />
                <span class="description">آیدی یا لینک اینستاگرام را وارد کنید.</span>
            </td>
        </tr>
        <tr>
            <th><label for="telegram">تلگرام</label></th>
            <td>
                <input type="text" name="telegram" id="telegram"
                    value="<?php echo esc_attr(get_the_author_meta('telegram', $user->ID)); ?>"
                    class="regular-text" /><br />
                <span class="description">آیدی یا لینک تلگرام را وارد کنید.</span>
            </td>
        </tr>
        <tr>
            <th><label for="linkedin">لینکدین</label></th>
            <td>
                <input type="text" name="linkedin" id="linkedin"
                    value="<?php echo esc_attr(get_the_author_meta('linkedin', $user->ID)); ?>"
                    class="regular-text" /><br />
                <span class="description">آدرس لینکدین را وارد کنید.</span>
            </td>
        </tr>
    </table>
<?php
}
add_action('personal_options_update', 'save_social_profiles_fields');
add_action('edit_user_profile_update', 'save_social_profiles_fields');
function save_social_profiles_fields($user_id)
{
    if (!current_user_can('edit_user', $user_id)) {
        return false;
    }
    update_user_meta($user_id, 'instagram', sanitize_text_field($_POST['instagram']));
    update_user_meta($user_id, 'telegram', sanitize_text_field($_POST['telegram']));
    update_user_meta($user_id, 'linkedin', sanitize_text_field($_POST['linkedin']));
}
reza delbaz ۲۷ تیر ۱۴۰۴، ۱۴:۴۵