Function Reference: geodir_on_wp_insert_post
Summary
Cache the listings which are edited by it’s author.
Global Values
- $gd_set_listing_edited
- (array) (required) Array of post ID which needs to notify admin on post edited.
- Default: None
Package
GeoDirectory
Parameters
- $post_ID
- (int) (required) Post ID.
- Default: None
- $post
- (WP_Post) (required) Post object.
- Default: None
- $update
- (bool) (required) Whether this is an existing listing being updated or not.
- Default: None
Change Log
Since: 1.5.9
1.6.18 Some times it sends email twice when listing edited – FIXED
1.6.24 See geodir_send_listing_edited_notification()
Filters
‘geodir_notify_on_listing_edited’ [Line: 5068]
Source File
geodir_on_wp_insert_post() is located in geodirectory-functions/general_functions.php [Line: 5055]
Source Code
function geodir_on_wp_insert_post( $post_ID, $post, $update ) { global $gd_set_listing_edited; if ( ! $update ) { return; } $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; $is_admin = is_admin() && ( ! defined( 'DOING_AJAX' ) || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) ? true : false; $inline_save = $action == 'inline-save' ? true : false; if ( empty( $post->post_type ) || $is_admin || $inline_save || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) { return; } if ( $action != '' && in_array( $action, array( 'geodir_import_export' ) ) ) { return; } $user_id = (int) get_current_user_id(); if ( $user_id > 0 && get_option( 'geodir_notify_post_edited' ) && ! wp_is_post_revision( $post_ID ) && in_array( $post->post_type, geodir_get_posttypes() ) ) { $author_id = ! empty( $post->post_author ) ? $post->post_author : 0; if ( $user_id == $author_id && ! is_super_admin() && empty( $gd_set_listing_edited[$post_ID] ) ) { if ( !empty( $gd_set_listing_edited ) ) { $gd_set_listing_edited = array(); } $gd_set_listing_edited[$post_ID] = true; } } }