Skip to content

Instantly share code, notes, and snippets.

@hivepress
Last active July 23, 2022 23:28
Embed
What would you like to do?
Make the profile image required for users #hivepress #users
<?php
add_filter(
'hivepress/v1/forms/user_update/errors',
function( $errors, $form ) {
$user = $form->get_model();
if ( $user && ! $user->get_image__id() ) {
$errors[] = 'Please upload the profile image.';
}
return $errors;
},
100,
2
);
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
$form['fields']['image']['statuses']['optional'] = null;
return $form;
},
1000
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment