namespace WPForms\Integrations\LiteConnect;
* Class RefreshAccessTokenTask.
class RefreshAccessTokenTask extends Integration {
const LITE_CONNECT_TASK = 'wpforms_lite_connect_refresh_access_token';
* RefreshAccessTokenTask constructor.
public function __construct() {
private function hooks() {
// Process the tasks as needed.
add_action( self::LITE_CONNECT_TASK, [ $this, 'process' ] );
* Creates a task to refresh the Lite Connect access token via Action Scheduler.
public function create() {
$action_id = wpforms()->obj( 'tasks' )
->create( self::LITE_CONNECT_TASK )
->once( time() + 6 * DAY_IN_SECONDS )
if ( $action_id === null ) {
'Lite Connect: error creating the AS task',
'task' => self::LITE_CONNECT_TASK,
[ 'type' => [ 'error' ] ]
* Process the task to regenerate the access token.
public function process() {
$this->get_access_token( $this->get_site_key(), true );