-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadvanced-form-submission-step.php
66 lines (52 loc) · 1.43 KB
/
advanced-form-submission-step.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: Advanced Form Submission Step
* Description: Provides custom logic for assigning a Form Submission step.
* Version: 1.0
* Author: Steven Henty
* Author URI: http://www.stevenhenty.com
* License: GPL-3.0+
*
* Copyright 2017 Steven Henty
*
* Requires Gravity Flow 1.8.1+ and the Form Connector Extension 1.2.1+
*/
add_action( 'gravityflow_loaded', function () {
class Gravity_Flow_Advanced_Form_Submission extends Gravity_Flow_Step_Form_Submission {
public $_step_type = 'advanced_form_submission';
public function get_settings() {
$settings = parent::get_settings();
// Remove the first four settings related to assignees.
for ( $i = 0; $i <= 3; $i ++ ) {
unset( $settings['fields'][ $i ] );
}
return $settings;
}
/**
* Returns the label for the step type.
*
* @return string
*/
public function get_label() {
return 'Advanced Form Submission';
}
/**
* Return the assignees.
*
* @return Gravity_Flow_Assignee[]
*/
public function get_assignees() {
// This is just an example.
// Perform your logic to select assignee keys.
$assignee_keys = array(
'user_id|1',
);
foreach ( $assignee_keys as $assignee_key ) {
// Check the user or role exists before adding.
$this->maybe_add_assignee( $assignee_key );
}
return $this->_assignees;
}
}
Gravity_Flow_Steps::register( new Gravity_Flow_Advanced_Form_Submission() );
}, 200 );