Hide profile settings from regular users

Hello, I would like to limit the profile information section to only users with a membership. I am using memberships to separate my Vendors from regular users, so I would like to hide the Profile Information section from regular users completely. Is there a snippet for this?? I have used a snippet in the past to limit what regular users can see, so I was hoping this would be similar!

Please try this PHP snippet. Please change membership_plan_id on the membership plan id which the user needs to have to have access to the account settings page

add_filter( 
	'hivepress/v1/templates/user_edit_settings_page', 
	function ($template){
		if ( hivepress()->get_version( 'memberships' ) ) {
			$membership = \HivePress\Models\Membership::query()->filter(['user' => get_current_user_id()])->get_first();
			
				if(!$membership || membership_plan_id !== $membership->get_plan__id()){
					wp_redirect(home_url());
					exit;
				}
		}

		return $template;
	}, 
	1000
);

Hello! My original post was edited by someone, I am not trying to hide the entire profile settings section from users. I only want to hide the “Profile Info” section that lies within the profile settings.

Sorry for the confusion, do you mean hiding specific fields within the profile settings form? There’s no other profile info section in the account, there’s a single profile settings form in Account/Settings.

Yes, I mean hiding the “Profile Info” field section inside of the profile settings. I just want to hide that field only from regular users being able to use it. I’m using it as a biography section for my vendors.

This is the field I wish to hide from regular users. It is inside the profile settings.

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		if(current_user_can('edit_posts')){
			return $form;
		}
		
		unset($form['fields']['description']);

		return $form;
	},
	1000
);

Perfect, thank you!

I have another question on the same topic! Is there a snippet on making the profile image optional only for that regular user?? I want my membership/vendors profiles to require the profile image, but regular users it is not necessary. I have tried manipulating some snippets to do this, and I am successful in hiding the profile image from the regular user, but it is still trying to require an image even though there is no field to insert an image since I activated the snippet to hide it from those regular users.

Please try this PHP snippet

add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		$vendor = \HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
				]
			)->get_first_id();
		
		if(!$vendor){
			return $form;
		}
		
		$form['fields']['image']['statuses']['optional'] = null;

		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/forms/user_update_profile',
	function( $form ) {
		$form['fields']['image']['statuses']['optional'] = null;

		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/models/vendor/fields',
	function($fields){
		if(isset($fields['image'])){
			$fields['image']['required'] = true;
		}
		
		return $fields;
	},
	1000
);

Hello, that does not seem to work. It did not change anything. I disabled all other snippets related to the Profile Image and it still nothing.
To clarify, I would like the Profile image to be required for Vendors, and optional for regular users.

Please try this PHP snippet instead. It will also show an error if the vendor tries to save account settings without a profile image or if the user tries to complete the Complete Profile form without a profile image to become a vendor

add_filter(
	'hivepress/v1/forms/user_update/errors',
	function( $errors, $form ) {
		if(!empty($errors)){
			return $errors;
		}
		
		$vendor = \HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
				]
			)->get_first_id();
		
		if(!$vendor){
			return $errors;
		}
		
		$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_profile/errors',
	function( $errors, $form ) {
		if(!empty($errors)){
			return $errors;
		}
		
		$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 ) {
		$vendor = \HivePress\Models\Vendor::query()->filter(
				[
					'user' => get_current_user_id(),
				]
			)->get_first_id();
		
		if(!$vendor){
			return $form;
		}
		
		$form['fields']['image']['statuses']['optional'] = null;

		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/forms/user_update_profile',
	function( $form ) {
		$form['fields']['image']['statuses']['optional'] = null;

		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/models/vendor/fields',
	function($fields){
		if(isset($fields['image'])){
			$fields['image']['required'] = true;
		}
		
		return $fields;
	},
	1000
);

That works, thank you!