חיפוש ]

הוספת שדות נוספים לעמוד פרופיל המשתמש

הוסיפו את הקוד הבא לקובץ functions.php בכדי להוסיף שדות משלכם לעמוד פרופיל המשתמש בלוח הבקרה של וורדפרס.


// CUSTOM USER PROFILE FIELDS
function my_custom_userfields( $contactMethods ) {

    // ADD CONTACT CUSTOM FIELDS
    $contactMethods['contact_phone_office']     = 'Office Phone';
    $contactMethods['contact_phone_mobile']     = 'Mobile Phone';
    $contactMethods['contact_office_fax']       = 'Office Fax';

    // ADD ADDRESS CUSTOM FIELDS
    $contactMethods['address_line_1']       = 'Address Line 1';
    $contactMethods['address_line_2']       = 'Address Line 2 (optional)';
    $contactMethods['address_city']         = 'City';
    $contactMethods['address_state']        = 'State';
    $contactMethods['address_zipcode']      = 'Zipcode';
}
add_filter('user_contactmethods','my_custom_userfields',10,1);

בכדי להציג שדות אלו ניתן להשתמש באחת מהמתודות הבאות:

the_author_meta('facebook', $current_author->ID)
<?php $current_author = get_userdata(get_query_var('author')); ?>
<p><a href="<?php echo esc_url($current_author->contact_phone_office);?>" title="office_phone"> Office Phone</a></p>
מצאתם טעות בקוד? הסניפט לא עובד לכם? רישמו לי בתגובות ואני מבטיח לטפל בכך במהרה ולספק סניפט תקין...

השאירו תגובה

הוסיפו קוד באמצעות הכפתורים מטה. למשל, בכדי להוסיף PHP לחצו על הכפתור PHP והוסיפו את הקוד בתוך השורטקוד. מצאתם שגיאה בפוסט? עדכנו אותנו...

Savvy WordPress Development official logo