Change value of radio button after 90 days

Hi, I currently am getting the days since a person signed up for each entry and I have the value for all entries radio button. I just don’t know how to actually change that value to the other option after 90 days have passed. I’ve been looking at the documentation for the last few weeks and I just can’t find a way to do this. Does anyone have any suggestions? If you need me to paste my code here let me know.

Thanks!

Go ahead and paste your code here. Thank you.

$form_id = 1;
$search_criteria = array();
$sorting = array( 'key' => '15', 'direction' => 'ASC' );
$paging  = array( 'offset' => 0, 'page_size' => 100 );
$total_count = 0;
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );   

$currentdate = date("Y-m-d");

foreach ($fixedentries as $entry) {
		 
     $entry_date = rgar( $entry, '15' );
     $email_im_holding = rgar( $entry, '31' );

$dateDiff = dateDiffInDays($currentdate, $entry_date);
	if ( count( array_unique( $entry ) ) < count( $entry ) ) {
		if ($dateDiff >= 90){
			
			/* change $email_im_holding value to "Holding Account" */

		} else{
			
			/* do nothing */
		}
	}
}

I’d basically need it to trigger each day or even on email notification sent then to change the value. Is there an action that can do this in gravity forms? Or a workaround for this?

How much of this is working, and what do you still need help with?

I just need help with how to change the value for the radio button field $email_im_holding to “Holding Account” from “Normal Account”. the
if ($dateDiff >= 90){
works fine when an entry is over 90 days. Then I don’t know how to trigger this so it checks each day I’d assume as a cron job.

Got it. If you need to check every day, then yes, you need to run this as a cron job. Look into “wp cron”:

https://developer.wordpress.org/plugins/cron/scheduling-wp-cron-events/

Or if you have command line access and WP CLI you could use the server cron, and a WP CLI script for Gravity Forms:

Ok, the cronjob should work fine but do you know of a way to change the value for a radio button while not actually on the form page or editing the form?

You can do it with the Gravity Forms CLI add-on:

or using API functions:

Thanks, I was able to get it to work he functions.php file but I want it to run only once a day so I moved it over to a new php file but I’m getting “Uncaught Error: Class ‘GFAPI’ not found in …” errors. I’m guessing I need to import the class but I don’t know which class I would import from gravity forms to get it to work. Any Ideas? Thanks!

I figured it out, I created a custom plugin and added the code to the php file and wrapped it in gravity forms custom cron job

add_action( 'gravityforms_cron', function() {

Thanks for your help.

1 Like

Very cool. Thank you for the update.