|
| 1 | +--- |
| 2 | +lang: php |
| 3 | +--- |
| 4 | + |
| 5 | +<!-- |
| 6 | + This source file is part of the open source project |
| 7 | + ExpressionEngine User Guide (https://github.com/ExpressionEngine/ExpressionEngine-User-Guide) |
| 8 | +
|
| 9 | + @link https://expressionengine.com/ |
| 10 | + @copyright Copyright (c) 2003-2020, Packet Tide, LLC (https://packettide.com) |
| 11 | + @license https://expressionengine.com/license Licensed under Apache License, Version 2.0 |
| 12 | +--> |
| 13 | + |
| 14 | +# Members Fieldtype Extension Hooks |
| 15 | + |
| 16 | +[TOC=3] |
| 17 | + |
| 18 | +### `member_relationships_display_field($entry_id, $field_id, $sql)` |
| 19 | + |
| 20 | +| Parameter | Type | Description | |
| 21 | +| ---------- | -------- | ------------------------------------------------------- | |
| 22 | +| \$entry_id | `Int` | Entry ID of entry being edited. | |
| 23 | +| \$field_id | `Int` | Field ID of field currently being loaded. | |
| 24 | +| \$sql | `String` | Compiled SQL about to be run to gather related members. | |
| 25 | +| Returns | `Array` | Result Array of query result. | |
| 26 | + |
| 27 | +Allows developers to modify the existing query that retrieves related members for the publish field or to perform their own queries to return related members. |
| 28 | + |
| 29 | +How it's called: |
| 30 | + |
| 31 | + if (ee()->extensions->active_hook('member_relationships_display_field') === TRUE) |
| 32 | + { |
| 33 | + $related = ee()->extensions->call( |
| 34 | + 'member_relationships_display_field', |
| 35 | + $entry_id, |
| 36 | + $this->field_id, |
| 37 | + ee()->db->_compile_select() |
| 38 | + ); |
| 39 | + } |
| 40 | + else |
| 41 | + { |
| 42 | + $related = ee()->db->get()->result_array(); |
| 43 | + } |
| 44 | + |
| 45 | +NOTE: **Note:** To use this hook, you can either add to the existing Active Record call, or call `ee()->db->_reset_select()` to cancel the Active Record call and start your own, or modify the passed compiled SQL. |
| 46 | + |
| 47 | +### `member_relationships_post_save($ships, $entry_id, $field_id)` |
| 48 | + |
| 49 | +| Parameter | Type | Description | |
| 50 | +| ---------- | ------- | ---------------------------------------------- | |
| 51 | +| \$ships | `Array` | Array of member IDs to be related to the entry. | |
| 52 | +| \$entry_id | `Int` | Entry ID of entry being saved. | |
| 53 | +| \$field_id | `Int` | Field ID of field currently being saved. | |
| 54 | +| Returns | `Array` | Array of relationships. | |
| 55 | + |
| 56 | +Allows developers to modify or add to the relationships array before saving. |
| 57 | + |
| 58 | +How it's called: |
| 59 | + |
| 60 | + $ships = ee()->extensions->call('member_relationships_post_save', $ships, $entry_id, $field_id); |
0 commit comments