maritimefox
Forum Replies Created
-
Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Pre-populating location with page slugwhat I want to achieve is for a business or customer to enter their postcode and for that postcode to follow them as they journey through the website. So for a business that registers they can only post ads in that postcode area and for a customer that registers they can only see the ads/offers in that postcode area.
Maybe I’m trying to achieve something that is not possible with WPAdverts?
add_filter( “adverts_form_load”, function( $form ) {
if( $form[“name”] != “advert” || is_admin() ) {
return $form;
}
foreach( $form[“field”] as $k => $f ) {
if( $f[“name”] == “adverts_location” ) {
$form[“field”][$k][“attr”] = array( “readonly” => “readonly” );
}
}
return $form;
} );
add_filter( “adverts_form_bind”, function( $form ) {
$form->set_value( “adverts_location”, “mepr_business_postcode” );
return $form;
} );Forum: Plugins
In reply to: [WPAdverts - Classifieds Plugin] Pre-populating location with page slugI have applied the code to the functions.php of my theme but I suspect I have made an error as it doesn’t appear to be showing what I expected to see.
I added a custom field to memberpress with a slug of “mepr_home_postcode”. In this example home postcode would be bb3-darwen
This is what I entered into the “xxx” in the code you supplied.
What I expected to see what where the ad is displayed.
https://mywebsite.com/bb3-darwen/offer/test-wednesday/
Additionally in the author manager I want it to be location specific
https://postcodeoffers.co.uk/bb3-darwen/author-manager/
Am I expecting too much of this piece of code?
Thanks,
J