Skip to content

Instantly share code, notes, and snippets.

@hivepress
Last active June 8, 2023 00:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hivepress/16fa87cfcae95e2927bea6d802d1a12d to your computer and use it in GitHub Desktop.
Save hivepress/16fa87cfcae95e2927bea6d802d1a12d to your computer and use it in GitHub Desktop.
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