Advertisement
elenasaygo

Oxygen condition

Nov 20th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. global $resident_input;
  2.  
  3. function getResidentInput(){
  4. $resident_input = '';
  5. if(isset($_POST['resident']))
  6. {
  7. $resident_input = $_POST['resident'];
  8. echo "<br>Resident input1: $resident_input<br>";
  9. }
  10. return $resident_input;
  11. }
  12.  
  13. echo "<br>Resident input2: $resident_input<br>";
  14.  
  15. if ( function_exists( 'oxygen_vsb_register_condition' ) ) {
  16.  
  17. oxygen_vsb_register_condition(
  18. // Condition Name
  19. 'Is WA Resident',
  20.  
  21. // Values: The array of pre-set values the user can choose from.
  22. // Set the custom key's value to true to allow users to input custom values.
  23. array(
  24. 'options' => array( 'Yes', 'No' ),
  25. 'custom' => false,
  26. ),
  27.  
  28. // Operators
  29. array( '==' ),
  30.  
  31. // Callback Function: Name of function that will be used to handle the condition
  32. 'wpdd_is_waresident_callback',
  33.  
  34. // Condition Category: Default ones are Archive, Author, Other, Post, User
  35. 'Other'
  36. );
  37.  
  38. }
  39.  
  40. /**
  41. * Callback function to handle the condition.
  42. * @param mixed $value Input value - in this case, true or false selected by the user.
  43. * @param string $operator Comparison operator selected by the user.
  44. *
  45. * @return boolean true or false.
  46. */
  47. function wpdd_is_waresident_callback( $value, $operator ) {
  48. echo "Value: $value";
  49. echo "<br>Resident input3: " . getResidentInput() . "<br>";
  50. if ( getResidentInput() === $value ) {
  51. return true;
  52. } else {
  53. return false;
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement