Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Created March 23, 2017 17:04
Show Gist options
  • Select an option

  • Save kjohnson/6468a0dd474b59f795f5af4e5a82f719 to your computer and use it in GitHub Desktop.

Select an option

Save kjohnson/6468a0dd474b59f795f5af4e5a82f719 to your computer and use it in GitHub Desktop.
An example "Resume" action for emulating the halt/redirect/resume process.
<?php if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'ninja_forms_register_actions', function( $actions ){
include_once 'resume-action.php';
$actions[ 'resume' ] = new Foo_ResumeAction();
return $actions;
});
<?php if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Class NF_Action_Custom
*/
final class Foo_ResumeAction extends NF_Abstracts_Action
{
/**
* @var string
*/
protected $_name = 'resume';
/**
* @var string
*/
protected $_timing = 'late';
/**
* @var int
*/
protected $_priority = 0;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->_nicename = __( 'Resume', 'ninja-forms' );
}
/**
* @param array $action_settings
* @param int|string $form_id
* @param array $data
* @return array $data
*/
public function process($action_settings, $form_id, $data )
{
if( ! isset( $data[ 'resume' ] ) ) {
$data['halt'] = TRUE;
$data['actions']['redirect'] = add_query_arg('nf_resume', $form_id, wp_get_referer());
}
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment