In the action user_new_form
, the parameter $user
returns a string add-new-user
.
I've used esc_attr( get_the_author_meta( '_typeuser', $user->ID ) );
but I get an error.
Another question on the topic is non-response at the moment but I've patched the problem with:
/* PROFIL FIELD */
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
add_action( 'user_new_form', 'my_show_extra_profile_fields');
function my_show_extra_profile_fields( $user ) {
if(is_string($user) === true){
$user = new stdClass();//create a new
$user->ID = -9999;
}
$newsletter = esc_attr( get_the_author_meta( '_newsletter', $user->ID ) );
unset($user);
}
How we can fix this problem without creating an object and setup $user->ID
to -9999
for new user?
$type
, not$user
. Presumably thatget_the_author_meta()
line is in your callback for this hook, so you know the user can't exist? So you can't use any ID?if(current_filter() == 'user_new_form'