Php Wordpress Multisite在注册时添加自定义字段,然后显示在配置文件页面中

Php Wordpress Multisite在注册时添加自定义字段,然后显示在配置文件页面中,php,wordpress,Php,Wordpress,我在互联网上搜索,但在用户激活他们的博客/网站后,找不到如何添加或更新元数据 我想添加这些字段,以便用户可以在他们的个人资料页面中看到他们额外的元/自定义字段 我的wp-signup.php文件中有以下代码: $signup_meta = array( 'organization_address'=>$_POST['organization_address'], 'organization_name'=>$_POST['organization

我在互联网上搜索,但在用户激活他们的博客/网站后,找不到如何添加或更新元数据

我想添加这些字段,以便用户可以在他们的个人资料页面中看到他们额外的元/自定义字段

我的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>
add_操作('show_user_profile'、'my_show_extra_profile_fields');
添加操作(“编辑用户配置文件”、“我的显示额外配置文件”字段);
函数my\u show\u extra\u profile\u字段($user)
{
康塔克廷酒店
福纳文:

我想我还没有完全理解这里的问题…但我看到的是,你正在尝试做一个注册表,使用非规则字段并将其保存为元数据。你的想法是正确的,但功能我不太确定

现在还不清楚您是想在管理面板内部还是外部执行此操作,因此,我建议

创建用户检索其用户名、密码和电子邮件,使用

wp_create_user( $username, $password, $email ); // Go to codex 

此函数将返回所创建的给定用户的ID,然后您将获得所有这些帖子,并在foreach或其他应用程序中使用此其他函数

add_user_meta( $user_id, $meta_key, $meta_value, $unique ); // Go to codex 

最后,在编辑页面上,或者在您想要显示它的地方,您可以使用

get_user_meta($user_id, $key, $single); // Go to codex