Skip to content

Instantly share code, notes, and snippets.

@nayemDevs
Created September 14, 2016 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nayemDevs/e9204f1511abe13b5beeac519539c5c1 to your computer and use it in GitHub Desktop.
Save nayemDevs/e9204f1511abe13b5beeac519539c5c1 to your computer and use it in GitHub Desktop.
function wpufe_update_post_geo1( $post_id ) {
function gmw_update_post_type_post_location( $post_id ) {
// Return if it's a post revision
if ( false !== wp_is_post_revision( $post_id ) )
return;
// check autosave //
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
//check if user can edit post
if ( !current_user_can( 'edit_post', $post_id ) )
return;
//get the address from the custom field "location"
$address = get_post_meta( $post_id, 'location', true );
//varify that address exists. Otherwise abort the function.
if ( empty( $address ) )
return;
//include the update location file
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
//make sure the file included and the function exists
if ( !function_exists( 'gmw_pt_update_location' ) )
return;
//Create the array that will pass to the function
$args = array(
'post_id' => $post_id, //Post Id of the post
'address' => $address // the address we pull from the custom field above
);
//run the udpate location function
gmw_pt_update_location( $args );
}
gmw_update_post_type_post_location($post_id);
//execute the function whenever post type is being updated
//add_action( 'save_post_post', 'gmw_update_post_type_post_location' );
}
add_action( 'wpuf_add_post_after_insert', 'wpufe_update_post_geo1' );
function wpufe_update_post_geo2( $post_id ) {
function gmw_update_post_type_post_location( $post_id ) {
// Return if it's a post revision
if ( false !== wp_is_post_revision( $post_id ) )
return;
// check autosave //
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
//check if user can edit post
if ( !current_user_can( 'edit_post', $post_id ) )
return;
//get the address from the custom field "location"
$address = get_post_meta( $post_id, 'location', true );
//varify that address exists. Otherwise abort the function.
if ( empty( $address ) )
return;
//include the update location file
include_once( GMW_PT_PATH .'/includes/gmw-pt-update-location.php' );
//make sure the file included and the function exists
if ( !function_exists( 'gmw_pt_update_location' ) )
return;
//Create the array that will pass to the function
$args = array(
'post_id' => $post_id, //Post Id of the post
'address' => $address // the address we pull from the custom field above
);
//run the udpate location function
gmw_pt_update_location( $args );
}
gmw_update_post_type_post_location($post_id);
//execute the function whenever post type is being updated
//add_action( 'save_post_post', 'gmw_update_post_type_post_location' );
}
add_action( 'wpuf_edit_post_after_update', 'wpufe_update_post_geo2' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment