I added an admin notice to the subscribers profile screen to invite them to complete their profile's extra fields. How can the notice hide automatically when the user updates the profile? When a user updates the profile a new notice appears below the first one but the the invitation remains. Im using this code.
function wpse_user_welcome_notice() {
// Make sure that the user is assigned to the subscriber role, specifically.
$user = wp_get_current_user();
if ( !in_array( 'subscriber', $user->roles ) ) {
return;
}
// Make sure the profile is being viewed.
$screen = get_current_screen();
if (!$screen || ( 'profile' !== $screen->id ) ) {
return;
}
$class = 'notice notice-info is-dismissible';
// Customize the HTML to fit your preferences.
$message = '<p>Example text goes here.. </a></p>';
printf( '<div class="%1$s"><div class="subscriberProfile">%2$s</div></div>',
$class, $message );
}
add_action( 'admin_notices', 'wpse_user_welcome_notice' );