• Resolved edtaaffe

    (@edtaaffe)


    I can write C and JavaScript but never did any php. I wrote enough asp to be able to get by. I’m just beginning to get into it a little. My eye is not keen enough yet to spot an issue.
    I’m trying to implement emails to go out to a new user who submitted a CV and also to an employer who just added a job listing.

    I am making slight customisations to the user journey and will want to change the messages accordingly.

    I took the suggested code snippet without changes first and attempted adding it to functions.php via the jobscout theme customer page
    Up to this everything has gone well and it is beginning to shape up.

    When I add this code and try to UPDATE. I get an error message,
    I’ve tried all kinds, including commenting out sections and I cant see any obvious reason for the error.

    function listing_published_send_email($post_id) {
    	if( 'job_listing' != get_post_type( $post_id ) ) {
    		return;
    	}
    	$post = get_post($post_id);
    	$author = get_userdata($post->post_author);
    
    	$message = "
    	  Hi ".$author->display_name.",
    	  Your listing, ".$post->post_title." has just been approved at ".get_permalink( $post_id ).". Well done!
    	";
    	wp_mail($author->user_email, "Your job listing is online", $message);
    }
    
    add_action('pending_to_publish', 'listing_published_send_email');

    Can anybody suggest what the problem might be?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter edtaaffe

    (@edtaaffe)

    I fixed it by rewriting the function a little just to help me make sense of things,

    function listing_published_send_email($post_id) {
    	if( 'job_listing' != get_post_type( $post_id ) ) {
    		return;
    	}
    	$post = get_post($post_id);
    	$author = get_userdata($post->post_author);
        $title =$post->post_title;
    	$link = get_permalink( $post_id );
    	$message = "
    	  Hi ".$author->display_name.",
    	  Your listing, ".$title." has just been approved at ".$link.". Well done!";
    	  
    	wp_mail($author->user_email, "Your job listing is online", $message);
    }

    This worked without a hitch.

    I got cocky then and I tried the same approach with the other key email:

    function resume_published_send_email($post_id) {
    	if( 'job_listing' != get_post_type( $post_id ) ) {
    		return;
    	}
    	$post = get_post($post_id);
    	$author = get_userdata($post->post_author);
        $title =$post->post_title;
    	$link = get_permalink( $post_id );
    	$message = "
    	  Hi ".$author->display_name.",
    	  Your CV, ".$title." has just been approved and available to recruiters and employers at ".$link.". Good luck!";
    	$message = $message . "Our recruiter may contact you with tips for approaching specific employers and jobs. We wish you every success";  
    		
    	wp_mail($author->user_email, "Your CV is online", $message);
    }

    Please, if you have any knowledge of php, see if you can spot an error.

    Thanks

    Gaurav

    (@gaurav984)

    Hi there,

    Thanks for your interest in WP Job Manager! We do not support customizations – you can refer to our Support Policy:

    https://wpjobmanager.com/support-policy/

    Specifically:

    “We provide our products as-is. We cannot customize our products on-demand, nor can we support third-party customizations. A customization is anything that changes the way the products looks or functions relative to how we make our products available to you. We can do our best to offer advice and guidance, and direct you to the appropriate resources if you require assistance with customization, but we don’t take responsibility or endorse any third-party solutions for customized products.”

    We do provide some tutorials for basic customizations here:

    https://wpjobmanager.com/documentation/advanced-customisation/
    https://wpjobmanager.com/documentation/tutorials/

    You may want to look into one of these services for extensive and/or highly specific customizations:

    https://jobs.wordpress.net/

    Best,

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Email message code snippets cause an error when I try to implement them.’ is closed to new replies.