Skip Navigation

[Resolved] CRED notification code no longer working

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by eliseD-2 6 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#915005

I have long been using some code in my functions.php of my child theme that was sending an email to the author of the GRANDFATHER of the post being submitted. This was working fine until the recent TOOLSET updates.

Is it broken because of the grandparent situation being different now because of the new relationship structure?

Can you have a look at my code below and let me know if it should still work or not?

Thanks!

Elise

// Change notification email to evaluator author when submitting assignment
add_filter( 'cred_mail_header', 'notify_grandparent', 10, 4 );
function notify_grandparent( $headers, $formid, $postid, $num_notification ) {
if($formid != 704 ) return;
$num_notification = 0;
$current_user = get_current_user_id();
//get the "lab-categories" terms of current "ASSIGNMENTRESULTS" post
$terms = get_the_terms( $postid, 'lab-categories' );
$term_slugs = array();
foreach ( $terms as $key => $taxonomy ){
$term_slugs[] = $taxonomy->slug ;
}
//with above terms, pass it to get_posts function as parameter "tax_query":
$registrations = get_posts( array(
'author' => $current_user,
'post_type' => 'registration',
'tax_query' => array(
array(
'taxonomy' => 'lab-categories',
'field' => 'slug',
'terms' => $term_slugs,
),
),
));

$evaluator_id = get_post_meta( $registrations[0]->ID, "_wpcf_belongs_evaluator_id", true); // assumes Evaluator CPT slug is 'evaluator'
$evaluator = get_post( $evaluator_id );
$evaluator_author = get_user_by( 'ID', $evaluator->post_author );
$newheaders = array( 'To: ' . $evaluator_author->user_email );

return array_merge($headers, $newheaders);
}

#915158

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - Yes, to access the parent is different situation from Types version 3.0.

Could you please share problem URL and access details so that I can debug further and check what needs to be change. As well as, please share one test case which grandparent should be assigned with CRED form with which specific entry.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#919565

not a problem anymore