主题我的登录插件,如何更新字段

时间:2013-06-04 作者:Poisontonomes

我正在使用Theme my Login 一个客户端项目的插件,我在用户注册后更新配置文件字段时遇到问题;

我按照指示做了here 但它们似乎没有任何效果。如果有人能解释一下,那就太好了。

这是我当前的代码;

register-form.php

<p>
    <input
      type="text"
      name="phone_number" 
      id="phone_number<?php $template->the_instance(); ?>" 
      class="input" 
      value="<?php $template->the_posted_value( \'phone_number\' ); ?>" 
      size="20" 
      tabindex="20" 
      placeholder="Phone Number"
    />
</p>

profile-form.php

<p>
    <input 
      type="text" 
      name="phone_number" 
      id="phone_number" 
      value="<?php echo esc_attr( $profileuser->phone_number ); ?>" 
      class="regular-text" 
      placeholder="Phone Number"
    />
</p>

theme-my-login-custom.php

function tml_user_register( $user_id ) {
        // Phone Number
        if ( !empty( $_POST[\'phone_number\'] ) )
            update_user_meta( $user_id, \'phone_number\', $_POST[\'phone_number\'] );
}
add_action( \'user_register\', \'tml_user_register\' );

1 个回复
SO网友:Pat J

这个user_register 钩子仅在用户首次注册时激发。要在编辑用户屏幕上显示自定义配置文件数据,应使用edit_user_profile 挂钩(可能show_user_profile, 如果希望用户能够编辑自己的自定义配置文件信息)。

结束

相关推荐

making php value numeric

我在堆栈溢出上使用了此页面中的一些代码:Using wp_query is it possible to orderby taxonomy?这是一个能够根据分类法值对查询进行排序的函数。虽然它工作得很好,但我想更进一步。我从分类术语中检索到的值是一个数字。但是,如果我按这个数字排序,它会给出以下顺序:1 10 11 2 21 22,依此类推。我希望它能“正常”排序,1 2 3 5 9 11 15 21 22等等。根据谷歌的说法,我应该在值中加0,使其成为一个数值,但我不知道在这段代码中应该放在哪里。在某个