Function Reference: geodir_send_inquiry

Summary

Send enquiry to listing author

Description

This function let the user to send Enquiry to listing author. If listing author email not available, then admin
email will be used. Email content will be used WP Admin -> Geodirectory -> Notifications -> Other Emails -> Email
enquiry

Global Values

$wpdb
(object) (required) WordPress Database object.

Default: None

Package

GeoDirectory

Parameters

$request
(array) (required) {
The submitted form fields as an array.

Default: None

Change Log

Since: 1.0.0

Type

Array

Actions

‘geodir_after_send_enquiry’ [Line: 274]

‘geodir_before_send_enquiry_email’ [Line: 304]

‘geodir_after_send_enquiry_email’ [Line: 329]

Filters

‘geodir_inquiry_email_msg’ [Line: 285]

‘geodir_send_enquiry_after_submit_redirect’ [Line: 343]

Source File

geodir_send_inquiry() is located in geodirectory-functions/custom_functions.php [Line: 223]

Source Code

function geodir_send_inquiry( $request ) {
	global $wpdb;

	// strip slashes from text
	$request = ! empty( $request ) ? stripslashes_deep( $request ) : $request;

	$yourname      = sanitize_text_field($request['inq_name']);
	$youremail     = sanitize_email($request['inq_email']);
	$inq_phone     = sanitize_text_field($request['inq_phone']);
	$frnd_comments = sanitize_text_field($request['inq_msg']);
	$pid           = absint($request['pid']);

	$author_id  = '';

	if ( $pid && 'publish' == get_post_status ( $pid  ) ) {

		check_ajax_referer( 'send_inquiry_'.$pid );

		$p_post = get_post($pid);

		$author_id  = $p_post->post_author;

	}else{
		gd_die();
	}

	$to_email  = geodir_get_post_meta( $pid, 'geodir_email', true );
	$to_name   = geodir_get_client_name( $author_id );

	if ( $to_email == '' ) {
		$to_email = get_option( 'admin_email' );
	}

	/**
	 * Called after the send enquiry var have been set but before the email has been sent.
	 *
	 * @since 1.0.0
	 *
	 * @param array $request   {
	 *                         The submitted form fields as an array.
	 *
	 * @type string $sendact   Enquiry type. Default "send_inqury".
	 * @type string $pid       Post ID.
	 * @type string $inq_name  Sender name.
	 * @type string $inq_email Sender mail.
	 * @type string $inq_phone Sender phone.
	 * @type string $inq_msg   Email message.
	 *
	 * }
	 * @param string $type     The form type, default: `Enquiry`.
	 */
	do_action( 'geodir_after_send_enquiry', $request, 'Enquiry' );

	$client_message = $frnd_comments;
	$client_message .= '
' . __( 'From :', 'geodirectory' ) . ' ' . $yourname . '
' . __( 'Phone :', 'geodirectory' ) . ' ' . $inq_phone . '
' . __( 'Email :', 'geodirectory' ) . ' ' . $youremail . '

' . __( 'Sent from', 'geodirectory' ) . ' - ' . get_option( 'blogname' ) . '.'; /** * Filter client message text. * * @since 1.0.0 * * @param string $client_message Client message text. */ $client_message = apply_filters( 'geodir_inquiry_email_msg', $client_message ); /** * Called before the send enquiry email is sent. * * @since 1.0.0 * * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } */ do_action( 'geodir_before_send_enquiry_email', $request ); if ( $to_email ) { // strip slashes message $client_message = stripslashes_deep( $client_message ); geodir_sendEmail( $youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid'] );//To client email } /** * Called after the send enquiry email is sent. * * @since 1.0.0 * * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } */ do_action( 'geodir_after_send_enquiry_email', $request ); $url = get_permalink( $pid ); if ( strstr( $url, '?' ) ) { $url = $url . "&send_inquiry=success"; } else { $url = $url . "?send_inquiry=success"; } /** * Filter redirect url after the send enquiry email is sent. * * @since 1.0.0 * * @param string $url Redirect url. */ $url = apply_filters( 'geodir_send_enquiry_after_submit_redirect', $url ); wp_redirect( $url ); gd_die(); }