demo

User submitted Amount

Store on Site Options or Post Meta a value which will be increased by User submitted amount

TOTAL: 127

Add Custom PHP Script Action

It’s a basic Form widget, add as “Actions after submit” the “Custom PHP Script” action.

The “amount” key is the Custom ID set on the Amount Form field.

The “total” key is the Site Option key decided to store the Total amount of submitted values by users.

Saved in Site Option

				
					$total = get_option('total'); // read previous total
$total += $fields['amount']; // add the new donation amount
update_option('total', $total); // save to db
				
			

Saved in current Post Meta

				
					$post_id = $_POST['queried_id'];
$total = get_post_meta($post_id, 'total', true); // read previous total
$total += $fields['amount']; // add the new donation amount
update_post_meta($post_id, 'total', $total); // save to db
				
			

#6278