Hey Guys,
I need help with incorporating HTML into a PHP email function. The HTML I want incorporate is a email template, The PHP is used to send an email message to employers once they have submitted a job on my website (I run a job website). The HTML will override the message in the PHP function, so that can be removed. I’m just having difficulty with which parts that need to be removed so I can paste my HTML template code. Any help would be appreciated greatly.
<?php /** * This code can be placed inside a custom plugin, or the theme functions.php file. * * The admin email is simply an array of content which is ran through a filter then 'imploded' and sent. * The content can be customised through a filter. * * The default content looks like this in the plugin: * * $message = apply_filters( 'create_job_application_notification_message', array( * 'greeting' => __( 'Hello', 'wp-job-manager-applications' ), * 'position' => sprintf( "\n\n" . __( 'A candidate (%s) has submitted their application for the position "%s".', 'wp-job-manager-applications' ), wp_kses_post( $candidate_name ), get_the_title( $job_id ) ), * 'before_message' => '', * 'start_message' => "\n\n-----------\n\n", * 'message' => wp_kses_post( $application_message ), * 'end_message' => "\n\n-----------\n\n", * 'view_resume' => $dashboard_link ? sprintf( __( 'You can view this and any other applications here: %s.', 'wp-job-manager-applications' ), $dashboard_link ) : __( 'You can view the applications from your dashboard.', 'wp-job-manager-applications' ), * 'contact' => "\n" . sprintf( __( 'You can contact them directly at: %s.', 'wp-job-manager-applications' ), $candidate_email ), * ), $application_id ); * * Let's hook a function into this filter: */ add_filter( 'create_job_application_notification_message', 'custom_create_job_application_notification_message', 10, 2 ); /** * This is the hooked in function! * @param array $message The content for the email * @param int $application_id The ID of the application post * @return array Your new content */ function custom_create_job_application_notification_message( $message, $application_id ) { // First, lets remove the contact line: unset( $message['contact'] ); // Lets add a custom field on the end of the email $message['custom_content'] = "\n\n" . 'Some custom field: ' . get_post_meta( $application_id, 'custom_field', true ); // Return the new message return $message;