Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Conditional Form Actions for ACFE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plugins
Conditional Form Actions for ACFE
Commits
63fcaa2c
Commit
63fcaa2c
authored
10 months ago
by
Christian Wach
Browse files
Options
Downloads
Patches
Plain Diff
Fire "acfe/form/submit" action before redirection
parent
cb22ea4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/form-actions/cfafa-form-action-redirect.php
+40
-27
40 additions, 27 deletions
includes/form-actions/cfafa-form-action-redirect.php
with
40 additions
and
27 deletions
includes/form-actions/cfafa-form-action-redirect.php
+
40
−
27
View file @
63fcaa2c
...
...
@@ -119,12 +119,39 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base {
// Populate Redirect data array.
$conditional_redirect
=
$this
->
form_redirect_data
(
$form
,
$current_post_id
,
$action
);
// Do the Redirect with the data from the Form.
$conditional_redirect
=
$this
->
form_redirect_perform
(
$conditional_redirect
);
// Save the results of this Action for later use.
$this
->
make_action_save
(
$action
,
$conditional_redirect
);
// Check Conditional.
if
(
!
$this
->
form_conditional_check
(
$conditional_redirect
)
)
{
return
;
}
// Strip out any empty Fields.
$redirect_data
=
$this
->
form_data_prepare
(
$conditional_redirect
);
// Sanity check.
if
(
empty
(
$redirect_data
[
'redirect_url'
]
)
)
{
return
;
}
/**
* Fire the ACF Extended action.
*
* This is to allow any plugins that perform administrative tasks (e.g. saving
* form submissions) to act before the redirect.
*
* @since 0.1.1
*
* @param array $redirect_data The array of Redirect data.
* @param array $form The array of Form data.
*/
do_action
(
'acfe/form/submit'
,
$form
,
$post_id
);
// Do the redirect.
wp_safe_redirect
(
$redirect_data
[
'redirect_url'
]
);
exit
;
}
/**
...
...
@@ -235,42 +262,28 @@ class CFAFA_Form_Action_Redirect extends CFAFA_Form_Action_Base {
}
/**
* C
onditionally performs the redirect
given data from mapped Fields.
* C
hecks the Conditional Field
given data from mapped Fields.
*
* @since 0.1
* @since 0.1
.1
*
* @param array $redirect_data The array of Redirect data.
* @return
array|bool $redirect The Redirect data array, or false on failure
.
* @return
bool $continue True if the Action should continue or false to skip
.
*/
public
function
form_redirect_perform
(
$redirect_data
)
{
public
function
form_conditional_check
(
$redirect_data
)
{
// Approve by default.
$continue
=
true
;
// Skip if the Redirect Conditional Reference Field has a value.
if
(
!
empty
(
$redirect_data
[
'redirect_conditional_ref'
]
)
)
{
// And the Redirect Conditional Field has no value.
if
(
empty
(
$redirect_data
[
'redirect_conditional'
]
)
)
{
return
$redirect_data
;
return
false
;
}
}
// Unset Redirect Conditionals.
if
(
isset
(
$redirect_data
[
'redirect_conditional'
]
)
)
{
unset
(
$redirect_data
[
'redirect_conditional'
]
);
}
if
(
isset
(
$redirect_data
[
'redirect_conditional_ref'
]
)
)
{
unset
(
$redirect_data
[
'redirect_conditional_ref'
]
);
}
// Strip out empty Fields.
$redirect_data
=
$this
->
form_data_prepare
(
$redirect_data
);
// Sanity check.
if
(
empty
(
$redirect_data
[
'redirect_url'
]
)
)
{
return
false
;
}
// Do the redirect.
wp_safe_redirect
(
$redirect_data
[
'redirect_url'
]
);
exit
;
// --<
return
$continue
;
}
...
...
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