add_action('frm_after_update_entry', 'update_used_passes', 10, 2);
function update_used_passes($entry_id, $form_id){
if ( $form_id == 35 ) {
$userid = $_POST['item_meta'][867];// 867 is the ID of the userID field
$used_passes = $_POST['item_meta'][875];// 875 is the ID of the used passes field
$pass_status = $_POST['item_meta'][970];// 970 is the ID of the pass status field
if ( $userid && $pass_status=="Approved") {
// Get the current value.
$count = (int) get_field('passes_used', $userid);
// Increase it.
$count++;
update_field('passes_used', $count, $userid);
}
}}
it doesn't work
Turn on WordPress debugging and use error_log to output information to tell you where it's going wrong. First verify that the function is being called and then output values along the way to see what's happening.
Please login or Register to submit your answer