欢迎使用,或者使用传递给user\\u id的edit\\u user\\u profile\\u update
add_action(\'edit_user_profile_update\', \'save_extra_fields_country_institution_user_form\' );
function save_extra_fields_country_institution_user_form($user_id){
# again do this only if you can
if(!current_user_can(\'manage_options\') || !current_user_can( \'edit_user\' ))
return false;
# save my custom field
$result = update_user_meta($user_id, \'verifier_assign_country\', \'test3\');
}
或者,当我在“edit\\u user\\u profile”上测试时,将传递整个用户对象,而不仅仅是用户id,因此请使用:
function save_extra_fields_country_institution_user_form($user){
# again do this only if you can
if(!current_user_can(\'manage_options\') || !current_user_can( \'edit_user\' ))
return false;
# save my custom field
$result = update_user_meta($user->ID, \'verifier_assign_country\', \'test\');
}
然而
https://codex.wordpress.org/Plugin_API/Action_Reference/edit_user_profile 更旨在向屏幕中添加字段,所以我认为您需要的是“edit\\u user\\u profile\\u update”