admin管理员组文章数量:1336632
I'm trying to save the initial value (saved_fname) of a new user created, when the registration is done from the admin panel it works but when I do it from REST API (Integromat) the user registers but the function doesnt work correctly. Same code, with no plugins installed.
Both methods, the function "saved_first_name" is executed but using REST API it is as if the values in the wp_usermeta table have not been registered yet, get_user_meta returns empty.
functions.php theme
function saved_first_name($user_id){
$saved_fname = get_user_meta($user_id, 'first_name', true);
update_user_meta($user_id, 'saved_fname', $saved_fname);
update_user_meta($user_id, 'imhere', 'yes');
}
add_action( 'user_register', 'saved_first_name' );
DB usermeta table result when registering user from admin panel:
- metakey: metavalue
- imhere: yes
- saved_fname: user1
- first_name: user1
- nickname: user1
DB usermeta table result when registering user from API REST:
- metakey: metavalue
- imhere: yes
- saved_fname: (empty-no value)
- first_name: user2
- nickname: user2
I can't find the reason for that behavior. Any suggestions are welcome & appreciated.
本文标签: functionsWhen are the user meta fields created in the database Admin vs Woo API REST
版权声明:本文标题:functions - When are the user meta fields created in the database? Admin vs Woo API REST 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742411639a2469907.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论