Support » Plugin: WPAdverts - Classifieds Plugin » Revise Contact Info section?

  • Resolved bdd

    (@bws-online)


    On my site, only members are able to view and add ads.

    The Contact Information section is pre-filled when a member goes to add an ad (Contact Person and Email) and the fields are both required, but I would like to NOT have them show up on the form. (I don’t want them to be able to add other details there/don’t want those fields editable.)

    Is there a way to either display that info without letting it be changed, or to NOT show it (without causing problems since they’re shown as required fields)?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    It’s not possible to remove the fields from the [adverts_add] as then the email and contact name would not be saved at all, you can however make these fields read-only by adding the code below in your theme functions.php file

    
    add_filter( "adverts_form_load", "make_readonly_name_and_email" );
    function make_readonly_name_and_email( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
      if( is_admin() ) {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( in_array($field["name"], array( "adverts_person", "adverts_email" ) ) ) {
            $form["field"][$key]["attr"] = array( "readonly" => "readonly" );
        }
      }
      return $form;
    }
    
    bdd

    (@bws-online)

    Thank you. I went with hiding the Contact Information section (via CSS), but I’ll also do this just in case.

    Thanks again.

    bdd

    (@bws-online)

    Actually — just tried this again — thought it was working but it’s not. What should I see with this? It’s still letting me revise those fields when adding an ad.

    Plugin Author Greg Winiarski

    (@gwin)

    After adding this code the “Contact Person” and “Contact Email” field should be locked in [adverts_add] shortcode.

    Like on the screenshot below it uses the code i sent in last message
    https://www.dropbox.com/s/jglhclo6u3kbo7w/person-and-email-locked.png?dl=0

    bdd

    (@bws-online)

    Thank you. I tried again and it’s working now. Apologies for the hassle. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.