Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideadude/0479e90879aa35580d6870345ba93114 to your computer and use it in GitHub Desktop.
Save ideadude/0479e90879aa35580d6870345ba93114 to your computer and use it in GitHub Desktop.
Example of one RH field depending on another.
<?php
// This code should be placed into context of adding RH fields
// like this: https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/
//define the fields
$fields = array();
$fields[] = new PMProRH_Field(
'budget', // input name, will also be used as meta key
'select', // type of field
array(
'options' => array( // <option> elements for select field
'' => '', // blank option - cannot be selected if this field is required
'lessthan2000' => '&lt; $2,000', // <option value="lessthan2000">&lt; $2,000</option>
'2000to5000' => '$2,000-$5,000', // <option value="2000to5000">$2,000-$5,000</option>
'5000to10000' => '$5,000-$10,000', // <option value="5000to10000">$5,000-$10,000</option>
'morethan10000' => '&gt; $10,000', // <option value="morethan10000">&gt; $10,000</option>
)
)
);
$fields[] = new PMProRH_Field(
'RFP',
'file',
array(
'label' => 'Upload your RPF',
'hint' => 'This will only show for budgets above 5000.',
'depends' => array( array( 'id' => 'budget', 'value' => array('5000to10000', 'morethan10000') ) ),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment