Users Can Remove Profile Image Even When Required

Hello,

I’m currently using this snippet to require profile images for users:

add_filter(
	'hivepress/v1/forms/user_update/errors',
	function( $errors, $form ) {
		$user = $form->get_model();

		if ( $user && ! $user->get_image__id() ) {
			$errors[] = 'Please upload a profile picture.';
		}

		return $errors;
	},
	100,
	2
);

The issue is that users can still remove their profile picture by clicking the ‘X’ button on their profile image. It automatically deletes their photo, and they aren’t required to save their settings.

Is there a way to prevent this? I’ve attached an image of the button below.
Capture

Thank you,
Andrew

Couldn’t you remove/hide the ‘X’ button with CSS display: none;?

Hello,

Good point, I hadn’t realized that uploading another image overrides the existing one, so I thought it needed to be there to remove it.

Thank you,
Andrew

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.