[英]how can i add new fields to registration page for new user registration in wordpress multisite?
[英]Wordpress Multisite Add custom fields on registration then show in Profile Page
我正在整个Internet上搜索,但是在用户激活其博客/站点后找不到如何添加或更新元数据。
我想添加一个,以便用户可以在他们的个人资料页面中看到他们的其他meta / custom字段。
我的wp-signup.php文件中包含以下代码:
$signup_meta = array(
'organization_address'=>$_POST['organization_address'],
'organization_name'=>$_POST['organization_name'],
'organization_number'=>$_POST['organization_number'],
'organization_address'=>$_POST['organization_address'],
'organization_zip'=>$_POST['organization_zip'],
'organization_city'=>$_POST['organization_city'],
'organization_country'=>$_POST['organization_country'],
'first_name'=>$_POST['first_name'],
'last_name'=>$_POST['last_name'],
'phone'=>$_POST['phone'],
'lang_id' => 1,
'public' => $public
);
wpmu_signup_blog($domain, $path, $blog_title, $email, $email, $signup_meta);
add_action('user_register', 'custom_register_extra_fields');
add_action('wpmu_activate_user', 'stjert_register_user_meta', 10, 3);
$meta_defaults = apply_filters( 'signup_create_blog_meta', $signup_meta );
confirm_blog_signup($domain, $path, $blog_title, $email, $email, $signup_meta);
然后在我的functions.php
文件中,我有以下代码:
add_action ( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action ( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields ( $user )
{
<h3>Kontaktinformasjon</h3>
<table class="form-table">
<tr>
<th><label for="first_name">Fornavn:</label></th>
<td>
<input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( get_the_author_meta( 'first_name', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label>Etternavn:</label></th>
<td>
<input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( get_the_author_meta( 'last_name', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label>Telefon:</label></th>
<td>
<input type="text" name="phone" id="phone" value="<?php echo esc_attr( get_the_author_meta( 'phone', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
</table>
我减少了代码,因为它太长了。
当我进入“个人资料页面”(wp-admin)时,看不到注册过程中拥有的那些自定义字段/元数值,我想也许没有保存它或什么?
有什么帮助吗? 请。 我真的对Wordpress陌生,“ Wordpress方式”对我来说非常困难。 感觉与MVC框架截然不同。
对你的帮助表示感谢!
谢谢!
PS:这是wp-signup.php http://pastebin.com/YcvHeHkC的 全部代码
我想我没有完全理解这里的问题...但是我看到的是,您正在尝试使用非常规字段填写注册表并将其另存为元数据。 您的思维方式是正确的,但是我不太确定其功能...
目前尚不清楚您是否要在管理面板内部还是外部执行此操作,所以,我的建议是
使用创建创建检索用户名,密码和电子邮件的用户
wp_create_user( $username, $password, $email ); // Go to codex
http://codex.wordpress.org/Function_Reference/wp_create_user
此函数将返回创建的给定用户的ID,而不是您获得所有这些帖子并在foreach或其他使用此其他函数的文件中
add_user_meta( $user_id, $meta_key, $meta_value, $unique ); // Go to codex
http://codex.wordpress.org/Function_Reference/add_user_meta
最后,在编辑页面上或要显示它的位置,您可以通过使用
get_user_meta($user_id, $key, $single); // Go to codex
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.