Title: Delete chars from Location
Last modified: April 5, 2019

---

# Delete chars from Location

 *  Resolved [falcobus](https://wordpress.org/support/users/falcobus/)
 * (@falcobus)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/delete-chars-from-location/)
 * Hi, when I add an new ad, I need for input text Location (adverts_location) to
   delete the first 4 chars – substr ($ location, 3), before inserting in the database.
   How should I do it?
 * For example: i write Location: AUSTRALIA and click to preview and click to SEND.
   Now, i need delete first 4 chars (leave AUST, stay RALIA, before inserting in
   the database.
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/delete-chars-from-location/#post-11394576)
 * Hi,
    if you want this to happen after preview and only when adding an Ad using[
   adverts_add] shortcode then you can add the code below in your theme functions.
   php file to do it
 *     ```
       add_action( "wpadverts_advert_saved", function( $post_id ) {
         $loc_cut = get_post_meta( $post_id, "_location_is_cut", true );
         if( $loc_cut == "1" ) {
           return;
         }
         $location = get_post_meta( $post_id, "adverts_location", true );
         $location = substr( $location, 3 );
         update_post_meta( $post_id, "adverts_location", $location );
       } );
       ```
   
 *  Thread Starter [falcobus](https://wordpress.org/support/users/falcobus/)
 * (@falcobus)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/delete-chars-from-location/#post-11395424)
 * Hi Greg, thanks, it s working perfect, when I add a new ad.
 * But if i want editing ad, Location stay without change. What I must to do if 
   I want delete first 4 chars also when ad is editing?
 * Thanks
 *  Plugin Author [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * (@gwin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/delete-chars-from-location/#post-11402443)
 * I suppose this will generate unpredictable results, when user will post from [
   adverts_add] location “Australia” it will be saved as “ralia” and when he will
   edit the Ad from [adverts_manage] page without updating the location it will 
   be cut to just “a”, so in order to have the location stay as “ralia” the user
   would need to change it first to “Australia”.
 * Either way, right now the [adverts_manage] shortcode does not support the wpadverts_advert_saved
   action so i am afraid it is not possible to apply this when updating an Ad at
   least not without modifying the original source code.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Delete chars from Location’ is closed to new replies.

 * ![](https://ps.w.org/wpadverts/assets/icon-256x256.png?rev=2423472)
 * [WPAdverts - Classifieds Plugin](https://wordpress.org/plugins/wpadverts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpadverts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpadverts/)
 * [Active Topics](https://wordpress.org/support/plugin/wpadverts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpadverts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpadverts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Greg Winiarski](https://wordpress.org/support/users/gwin/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/delete-chars-from-location/#post-11402443)
 * Status: resolved