2017-02-22 1 views
0

меня есть база данных «Коды» из enteries как 00123, 01392 и т.д.Добавить пользовательские поля в Wordpress зарегистрироваться и проверить, если он совпадает с entery в базе данных

Я хочу, чтобы добавить поле в мой Wordpress зарегистрироваться и проверить, он соответствует вводу в моей базе данных «Коды» в регистре пользователя. Не могли бы вы мне помочь?

ответ

0

Вы должны использовать Action крюк

add_action ('show_user_profile', 'my_fields'); 
add_action ('edit_user_profile', 'my_fields'); 

function my_fields ($user) 
{ 
?> 
    <h3>Extra profile information</h3> 
    <table class="form-table"> 
     <tr> 
      <th><label for="twitter">Twitter</label></th> 
      <td> 
       <input type="text" name="twitter" id="twitter" value="<?php echo esc_attr(get_the_author_meta('twitter', $user->ID)); ?>" class="regular-text" /><br /> 
       <span class="description">Please enter your Twitter username.</span> 
      </td> 
     </tr> 
    </table> 
<?php 
} 

add_action ('personal_options_update', 'my_fields_save'); 
add_action ('edit_user_profile_update', 'my_fields_save'); 

function my_fields_save($user_id) 
{ 
    if (!current_user_can('edit_user', $user_id)) 
     return false; 
    /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */ 
    update_usermeta($user_id, 'twitter', $_POST['twitter']); 
} 
+0

Спасибо, в какой файл я должен добавить этот код? – wander

Смежные вопросы