eZ 4.x Custom User Group Assignment Workflow

This is a simple workflow event that will extract a member type attribute (single select) and use it to assign the member into a group on register.

It catches not only self-registration, but updates made through the admin interface.

class HPMemberRegisterType extends eZWorkflowEventType
	const WORKFLOW_TYPE_STRING = 'hpmemberregister';

	public function __construct() 
		parent::__construct( HPMemberRegisterType::WORKFLOW_TYPE_STRING, 'HP Member Register' );
	public function execute ( $process, $event )
		$parameters = $process->attribute( 'parameter_list' );
		$ini = eZINI::instance( 'hpmember.ini' );

		$objectID = $parameters['object_id']; 
		$object = eZContentObject::fetch( $objectID );
		$nodeID = $object->attribute( 'main_node_id' );
		$node = eZContentObjectTreeNode::fetch( $nodeID );

		if ( $object->contentClassIdentifier() === 'member' ) {

			$dataMap = $object->dataMap();
			$memberTypeValue = $dataMap[ 'member_type' ]->content();
			$contentClass = $object->contentClass();
			$memberTypes = $contentClass->fetchAttributeByIdentifier( 'member_type' )->content();
			$memberType = $memberTypes['options'][$memberTypeValue[0]]['name'];
			$memberGroup = $ini->variable( 'MemberGroup', $memberType );
			if ( $memberGroup !== null ) 
				$node->setAttribute ( 'parent_node_id', $memberGroup );

		return eZWorkflowType::STATUS_ACCEPTED;
eZWorkflowEventType::registerEventType( HPMemberRegisterType::WORKFLOW_TYPE_STRING, 'hpmemberregistertype' );

.ini file:

<?php /* #?ini charset="utf-8"?

# The node id members with that type should be placed in

*/ ?>

You can place your nodes where you like. Be sure the names under [MemberGroup] are identical to the options in the selection attribute added to the class used for user registration. This code uses a custom Member class to distinguish eZ Users from site members.