Adding attachment fields to the registration form

Okay so I was able to get the registration field set easily by modifying some code:

add_filter(
	'hivepress/v1/forms/user_register',
	function ( $form ) {
		$form['fields'] = array_merge(
			$form['fields'],
			[
				'first_name' => [
					'required' => true,
					'_order'   => 1,
				],

				'last_name'  => [
					'required' => true,
					'_order'   => 2,
				],

				'dl_image' => [
					'required' => true,
					'label'    => 'Drivers License',
					'type'	   => 'file',
					'accept'   => 'image/png, image/jpeg',
					'_order'   => 3,
				],
			]
		);

		return $form;
	},
	100
);

add_action(
	'hivepress/v1/models/user/register',
	function( $user_id, $values ) {
		if ( isset( $values['first_name'] ) ) {
			update_user_meta( $user_id, 'first_name', $values['first_name'] );
		}

		if ( isset( $values['last_name'] ) ) {
			update_user_meta( $user_id, 'last_name', $values['last_name'] );
		}

		if ( isset( $values['dl_image'] ) ) {
			update_user_meta( $user_id, 'dl_image', $values['dl_image'] );
		}
	},
	10,
	2
);

But have been unsuccessful in getting the image to show up in the profile area. I know this is probably out of the scope, but if there is already a snippet that I can use to modify, that would be nice. Thank you for all you do. I do want to buy you all a drink haha

Please let me know if you also managed to retrieve and save the file on registration? This is the hardest part because attachments in WordPress require user ID (author). Displaying this attachment somewhere after the registration depends on how it’s stored.

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