Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Developer Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brienne
Developer Documentation
Commits
e6b3f9a8
Commit
e6b3f9a8
authored
8 years ago
by
Andie Hunt
Browse files
Options
Downloads
Patches
Plain Diff
hook_civicrm_membershipTypeValues: formatting fixes
parent
3f3298e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/hooks/hook_civicrm_membershipTypeValues.md
+29
-24
29 additions, 24 deletions
docs/hooks/hook_civicrm_membershipTypeValues.md
with
29 additions
and
24 deletions
docs/hooks/hook_civicrm_membershipTypeValues.md
+
29
−
24
View file @
e6b3f9a8
...
...
@@ -2,44 +2,49 @@
## Description
This hook is called when composing the array of membership
T
ypes and
their cost during a membership registration (new or renewal). Note the
hook is called on initial page load and also reloaded after submit (PRG
pattern). You can use it to alter the membership types when first
This hook is called when composing the array of membership
t
ypes and
their cost
s
during a membership registration (new or renewal). Note the
hook is called on initial page load and also reloaded after submit (
[
PRG
pattern
](
https://en.wikipedia.org/wiki/Post/Redirect/Get
)
). You can use it to alter the membership types when first
loaded, or after submission (for example if you want to gather data in
the form and use it to alter the fees).
## Definition
hook_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
```
php
hook_civicrm_membershipTypeValues
(
&
$form
,
&
$membershipTypeValues
)
{
```
## Parameters
-
$form the form object that is presenting the page
-
$membershipTypeValues the array of membership types and their
amount
-
object
`$form`
- the form object that is presenting the page
-
array
`$membershipTypeValues`
- the membership types and their amounts
## Examples
Give a 50% discount to some memberships in the sample data
function civitest_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
$membershipTypeValues[1]['name'] = 'General (50% discount)';
$membershipTypeValues[1]['minimum_fee'] = '50.00';
```
php
function
civitest_civicrm_membershipTypeValues
(
&
$form
,
&
$membershipTypeValues
)
{
$membershipTypeValues
[
1
][
'name'
]
=
'General (50% discount)'
;
$membershipTypeValues
[
1
][
'minimum_fee'
]
=
'50.00'
;
$membershipTypeValues[2]['name'] = 'Student (50% discount)';
$membershipTypeValues[2]['minimum_fee'] = '25.00';
}
$membershipTypeValues
[
2
][
'name'
]
=
'Student (50% discount)'
;
$membershipTypeValues
[
2
][
'minimum_fee'
]
=
'25.00'
;
}
```
Modify specific fee values
function mymodule_civicrm_membershipTypeValues( &$form, &$membershipTypeValues ) {
foreach ( $membershipTypeValues as &$values) {
if ( $values['name'] == 'General') {
$values['minimum_fee'] = "5.55";
}
if ( $values['name'] == 'Student') {
$values['minimum_fee'] = "2.22";
}
}
}
\ No newline at end of file
```
php
function
mymodule_civicrm_membershipTypeValues
(
&
$form
,
&
$membershipTypeValues
)
{
foreach
(
$membershipTypeValues
as
&
$values
)
{
if
(
$values
[
'name'
]
==
'General'
)
{
$values
[
'minimum_fee'
]
=
"5.55"
;
}
if
(
$values
[
'name'
]
==
'Student'
)
{
$values
[
'minimum_fee'
]
=
"2.22"
;
}
}
}
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment