And is it possible to prohibit unauthorized users from posting ads on the site, and if so, how – to do it?!
Hi,
go to wp-admin / Pages panel, edit the page with [adverts_add] shortcode and change the shortcode to [adverts_add requires=”read”] then only logged-in users will be able to post Ads.
See https://wpadverts.com/documentation/allow-users-to-post-ads-adverts_add/ for more details.
I’ve got one more question. How to make the users necessarily indicate the phone number when publishing an ad?
I’ve got one more question. How to make the users necessarily indicate the phone number when publishing an ads?
There is another problem. Other users see other people’s ads, and they can edit them. How to fix it? How to prevent users from editing other people’s ads?
1. you can make the phone field required by adding the code below in your theme functions.php file
add_filter( "adverts_form_load", "customize_adverts_add" );
function customize_adverts_add( $form ) {
if( $form['name'] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( $field["name"] == "adverts_phone" ) {
$form["field"][$key]["is_required"] = true;
$form["field"][$key]["validator"][] = array( "name" => "is_required" );
}
}
return $form;
}
2. where the users can edit other users Ads? On the page with [adverts_manage] shortcode or in wp-admin / Classifieds?
The wp-admin / Classifieds panel is available only to users with Editor or Administrator role, that is to users who manage the site and these users can edit all the uploaded Ads.
How to make a mandatory field for selecting a category when publishing an ad on a site?
In the code above change the line
if( $field["name"] == "adverts_phone" ) {
to
if( in_array( $field["name"], array( "adverts_phone", "advert_category" ) ) ) {
then both category and phone fields will be required.