• Resolved dorozhkinsa

    (@dorozhkinsa)


    Hello! Can you please tell me how to prevent unregistered users from posting ads on the site? Give thanks!

    • This topic was modified 6 years, 1 month ago by dorozhkinsa.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter dorozhkinsa

    (@dorozhkinsa)

    And is it possible to prohibit unauthorized users from posting ads on the site, and if so, how – to do it?!

    Plugin Author Greg Winiarski

    (@gwin)

    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.

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    Thank!

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    I’ve got one more question. How to make the users necessarily indicate the phone number when publishing an ad?

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    I’ve got one more question. How to make the users necessarily indicate the phone number when publishing an ads?

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    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?

    Plugin Author Greg Winiarski

    (@gwin)

    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.

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    How to make a mandatory field for selecting a category when publishing an ad on a site?

    Plugin Author Greg Winiarski

    (@gwin)

    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.

    Thread Starter dorozhkinsa

    (@dorozhkinsa)

    Thank you so much!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Prevent unregistered users from posting ads on the site’ is closed to new replies.