Skip Navigation

[Gelöst] E-Mail Alert

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user wanted his users to be able to subscribe to a notification type. Lets say the user has a Job type and wants to notify user when they subscribe to a notification of a particular job type.

Solution:

This can be done by creating a secondary CPT for the notifications where the user can create the notification type they want for a job.

So on this notification cpt it should have attributes from the Jobs CPT that can be used to match a notification for a Job type. The notification CPT must also have an email field.

Then you can use this code below to send an email to a notification post based on a matching custom field criteria.

//Job Alarm function
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data) {
    if ( $form_data['id'] == 67) {
        $job_type = get_post_meta($post_id, 'wpcf-position-normal',true);
        $job_stelle = (types_render_field( 'stelle-ist-geeignet-fur', array( 'id' => ''.$post_id.'') ));
        $notifications = get_posts('post_type=job-alarm');
        foreach ($notifications as $notification) {
            $email = get_post_meta($notification->ID, 'wpcf-e-mail', true);
            $notification_type = get_post_meta($notification->ID, 'wpcf-position-alarm',true);
            $notification_stelle = (types_render_field( 'stelle-ist-geeignet-fur-alarm', array( 'id' => ''.$notification->ID.'') ));
            if ( $job_type == $notification_type && count(array_intersect(explode(",",$job_stelle), explode(",",$notification_stelle))) > 0) {
                wp_mail($email, 'Dein Job Alarm: '.get_the_title($post_id), get_permalink($post_id)."HTML CODE CAN GO HERE");
            }
        }
    }
}
This support ticket is created vor 6 Jahren, 3 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 61 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von SteffenM1628 vor 6 Jahren, 2 Monaten.

Assistiert von: Shane.

Author
Artikel
#1099593

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Steffen,

No problem.

1. Yes you can use this on other sites, just ensure that the information in the code is matching the site you use it on such as the form id and the custom field slugs.

2. Yes you can add the title for the notification as well.

Example of how you would do this.

                wp_mail($email, 'Dein Job Alarm: '.get_the_title($post_id).' Notification Alarm: '.get_the_title($notification->ID), get_permalink($post_id)."HTML CODE CAN GO HERE");

This should work.

Please let me know if this helps.
Thanks,
Shane

#1100788

He Shane,

thank you soooo much for your help and support.

You are absolutly awesome!

cheers!!!!!!