将自定义字段添加到Wordpress注册表,并检查它是否与数据库中的Entry匹配
我有一个数据库“代码”的企业,如00123,01392等将自定义字段添加到Wordpress注册表,并检查它是否与数据库中的Entry匹配,wordpress,Wordpress,我有一个数据库“代码”的企业,如00123,01392等 我想在我的Wordpress注册表中添加一个字段,并检查它是否与用户注册表中数据库“Codes”中的Entry匹配。你能帮帮我吗?你需要使用动作钩 add_action ( 'show_user_profile', 'my_fields' ); add_action ( 'edit_user_profile', 'my_fields' ); function my_fields ( $user ) { ?> <h3&
我想在我的Wordpress注册表中添加一个字段,并检查它是否与用户注册表中数据库“Codes”中的Entry匹配。你能帮帮我吗?你需要使用动作钩
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'] );
}
add_操作('show_user_profile'、'my_fields');
添加操作(“编辑用户配置文件”、“我的字段”);
函数my_字段($user)
{
?>
额外配置文件信息
啁啾