Function Reference: geodir_payment_adminEmail

Summary

This function has not been documented yet.

Filters

‘geodir_payment_adminEmail_to’ [Line: 1702]

‘geodir_payment_adminEmail_subject’ [Line: 1713]

‘geodir_payment_adminEmail_message’ [Line: 1724]

‘geodir_payment_adminEmail_headers’ [Line: 1735]

Source Code

function geodir_payment_adminEmail($post_id, $user_id, $message_type, $extra = '') {
	$login_details = '';
	$to_message = '';
	$to_subject = '';
					
	if ($message_type == 'payment_success') {
		$subject = get_option('geodir_post_payment_success_admin_email_subject'); 
		$message = get_option('geodir_post_payment_success_admin_email_content'); 
	} elseif ($message_type == 'payment_fail') {
		$subject = get_option('geodir_post_payment_fail_admin_email_subject'); 
		$message = get_option('geodir_post_payment_fail_admin_email_content');
	} elseif ($message_type == 'payment_upgrade') {
		$subject = get_option('geodir_post_upgrade_success_email_subject_admin'); 
		$message = get_option('geodir_post_upgrade_success_email_content_admin');
	} elseif ($message_type == 'payment_renew') {
		$subject = get_option('geodir_post_renew_success_email_subject_admin'); 
		$message = get_option('geodir_post_renew_success_email_content_admin');
	} else {
		return false;
	}
	
	if (!empty($subject)) {
		$subject = __(stripslashes_deep($subject), 'geodirectory');
	}

	if (!empty($message)) {
		$message = __(stripslashes_deep($message), 'geodirectory');
	}
	
	$user_info = get_userdata($user_id);
	
	$toEmail =  get_option('site_email');
	$toEmailName = get_site_emailName();
	
	$sitefromEmail = get_option('site_email');
	$sitefromEmailName = get_site_emailName();
	
	$productlink = get_permalink($post_id);
	
	$post_info = get_post($post_id);
	
	$posted_date = $post_info->post_date;
	$listingLink =''.$post_info->post_title.'';
	$siteurl = home_url();
	$siteurl_link = ''.$siteurl.'';
	$loginurl = geodir_login_url();
	$loginurl_link = 'login';
	
	$fromEmail = $sitefromEmail;
	$fromEmailName = $sitefromEmailName;
	
	$search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#login_url#]','[#login_details#]','[#client_name#]', '[#posted_date#]', '[#transaction_details#]');
	$replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$loginurl_link,$login_details,$toEmailName, $posted_date, $extra);
	$message = str_replace($search_array,$replace_array,$message);
	
	$search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#subject#]','[#client_name#]', '[#posted_date#]');
	$replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$to_subject,$toEmailName, $posted_date);
	$subject = str_replace($search_array,$replace_array,$subject);
	
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
	$headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";

	/**
	 * Filter the admin email to address.
	 *
	 * @since 1.4.0
	 * @package GeoDirectory_Payment_Manager
	 * @param string $toEmail The email address the email is being sent to.
	 * @param int $post_id The post id of the post the email is regarding.
	 * @param string $message_type The type of email being sent.
	 * @param string $extra Transaction details if available.
	 */
	$toEmail = apply_filters('geodir_payment_adminEmail_to',$toEmail,$post_id, $user_id, $message_type, $extra);
	/**
	 * Filter the admin email subject.
	 *
	 * @since 1.4.0
	 * @package GeoDirectory_Payment_Manager
	 * @param string $subject The email subject.
	 * @param int $post_id The post id of the post the email is regarding.
	 * @param string $message_type The type of email being sent.
	 * @param string $extra Transaction details if available.
	 */
	$subject = apply_filters('geodir_payment_adminEmail_subject',$subject,$post_id, $user_id, $message_type, $extra);
	/**
	 * Filter the admin email message.
	 *
	 * @since 1.4.0
	 * @package GeoDirectory_Payment_Manager
	 * @param string $message The email message text.
	 * @param int $post_id The post id of the post the email is regarding.
	 * @param string $message_type The type of email being sent.
	 * @param string $extra Transaction details if available.
	 */
	$message = apply_filters('geodir_payment_adminEmail_message',$message,$post_id, $user_id, $message_type, $extra);
	/**
	 * Filter the admin email headers.
	 *
	 * @since 1.4.0
	 * @package GeoDirectory_Payment_Manager
	 * @param string $headers The email headers.
	 * @param int $post_id The post id of the post the email is regarding.
	 * @param string $message_type The type of email being sent.
	 * @param string $extra Transaction details if available.
	 */
	$headers = apply_filters('geodir_payment_adminEmail_headers',$headers,$post_id, $user_id, $message_type, $extra);
	
	$sent = wp_mail($toEmail, $subject, $message, $headers);
	if( !$sent && function_exists( 'geodir_error_log' ) ) {
		if ( is_array( $toEmail ) ) {
			$toEmail = implode( ',', $toEmail );
		}
		$log_message = sprintf(
			__( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ),
			$message_type,
			date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ),
			$toEmail,
			$subject
		);
		geodir_error_log( $log_message );
	}
}