我使用重力形式,我想知道如何使用我的SQL数据库表创建自定义表查找,这可能吗?
我尝试使用以下代码,但我认为这可能是错误的:
<?php
/********* User Custom Fields ***********/
add_action( 'show_user_profile', 'mytheme_extra_profile_fields' );
add_action( 'edit_user_profile', 'mytheme_extra_profile_fields' );
function mytheme_extra_profile_fields( $user ) {
$customData = get_user_meta($user->ID);
$enroll = (isset($customData['enroll'][0]) && $customData['enroll'][0] != '') ? $customData['enroll'][0] : '';
$department = (isset($customData['department'][0]) && $customData['department'][0] != '') ? $customData['department'][0] : '';
$designation = (isset($customData['designation'][0]) && $customData['designation'][0] != '') ? $customData['designation'][0] : '';
$unit = (isset($customData['unit'][0]) && $customData['unit'][0] != '') ? $customData['unit'][0] : '';
}
?>
<tr>
<th><?php esc_html_e('Enroll', 'mytheme'); ?></th>
<td>
<input type="text" name="custom_user_field_enroll" id="enroll" value="<?php echo $enroll; ?>" />
</td>
</tr>
<tr>
<th><?php esc_html_e('Department', 'mytheme'); ?></th>
<td>
<input type="text" name="custom_user_field_department" id="department" value="<?php echo $department ; ?>" />
</td>
</tr>
<tr>
<th><?php esc_html_e('Designation', 'mytheme'); ?></th>
<td>
<input type="text" name="custom_user_field_designation" id="designation" value="<?php echo $designation ; ?>" />
</td>
</tr>
<tr>
<th><?php esc_html_e('Unit', 'mytheme'); ?></th>
<td>
<input type="text" name="custom_user_field_unit" id="unit" value="<?php echo $unit ; ?>" />
</td>
</tr>
</table>