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 );
} );
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
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.