Skip to content

Commit

Permalink
chore: correctly register profile manager group field type
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed May 23, 2023
1 parent 5b4fc63 commit 6fd2544
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
13 changes: 0 additions & 13 deletions classes/ColdTrick/GroupTools/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,4 @@ public function load() {
$events->registerHandler('route:config', 'account:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register');
$events->registerHandler('route:config', 'action:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register');
}

/**
* {@inheritdoc}
*/
public function init() {
if (is_callable('profile_manager_add_custom_field_type')) {
profile_manager_add_custom_field_type('custom_group_field_types', 'group_tools_preset', elgg_echo('group_tools:profile:field:group_tools_preset'), [
'user_editable' => true,
'output_as_tags' => true,
'admin_only' => true,
]);
}
}
}
34 changes: 34 additions & 0 deletions classes/ColdTrick/GroupTools/Plugins/ProfileManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace ColdTrick\GroupTools\Plugins;

use ColdTrick\ProfileManager\FieldType;

/**
* Modifications for the Profile Manager plugin
*/
class ProfileManager {

/**
* Register a group profile field type
*
* @param \Elgg\Event $event 'types:custom_group_field', 'profile_manager'
*
* @return array
*/
public static function registerGroupFields(\Elgg\Event $event): array {
$result = $event->getValue();

$result[] = FieldType::factory([
'type' => 'group_tools_preset',
'name' => elgg_echo('group_tools:profile:field:group_tools_preset'),
'options' => [
'user_editable' => true,
'output_as_tags' => true,
'admin_only' => true,
],
]);

return $result;
}
}
5 changes: 5 additions & 0 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@
'\ColdTrick\GroupTools\Plugins\Groups::registerGroupTools' => [],
],
],
'types:custom_group_field' => [
'profile_manager' => [
'\ColdTrick\GroupTools\Plugins\ProfileManager::registerGroupFields' => [],
],
],
'validate:after' => [
'user' => [
'\ColdTrick\GroupTools\Membership::createUserEmailInvitedGroups' => [],
Expand Down

0 comments on commit 6fd2544

Please sign in to comment.