• Resolved jnorell

    (@jnorell)


    Hello,

    I’m working to make adverts_email optional; I’ve read through all the places in wpadverts proper as well as the addons we are using, and I find it’s used for payment and for registering user accounts, neither of which we are doing. We have your custom fields plugin, so I unchecked ‘Required’ for Email – no problem there.

    The one and I think only issue we have now is the contact form (‘Send Message’ button) is still visible even when there is no email address. It is trivial to hide that conditionally, and I’m asking if you would please incorporate this patch or something similar:

    
    --- a/wp-content/plugins/wpadverts/addons/contact-form/contact-form.php
    +++ b/wp-content/plugins/wpadverts/addons/contact-form/contact-form.php
    @@ -48,6 +48,7 @@ function adext_contact_form( $post_id ) {
         
         $show_form = false;
         $flash = null;
    +    $email = get_post_meta( $post_id, "adverts_email", true );
         $phone = get_post_meta( $post_id, "adverts_phone", true );
         $message = null;
         $form = new Adverts_Form( Adverts::instance()->get( "form_contact_form" ) );
    @@ -114,10 +115,12 @@ function adext_contact_form( $post_id ) {
         <?php echo $flash ?>
     
         <div class="adverts-single-actions">
    +        <?php if( ! empty( $email ) ): ?>
             <a href="#" class="adverts-button adverts-show-contact-form">
                 <?php esc_html_e("Send Message", "adverts") ?>
                 <span class="adverts-icon-down-open"></span>
             </a>
    +        <?php endif; ?>
    
    

    If you don’t want to, could you tell me if there are any other options to accomplish this? (ie. hide the contact form if the adverts_email is empty) Right now the best I can see is to remove the call to adext_contact_form() from the adverts_tpl_single_bottom action, then duplicate that function, make my changes, and hook my function instead. I’d rather not have to duplicate all that code for such a simple thing…

    Thanks!

    • This topic was modified 9 years ago by jnorell.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,
    I understand the first part. You want to have optional email field, and you achieved it using custom fields. But I do not understand the second issue. Could you help me to understand what you trying to achieve?

    Thread Starter jnorell

    (@jnorell)

    Sure, after doing the first part of making the email address optional, ads can of course be created without an email address. The problem is if there is no email address entered, the “Send Message” button still shows up; if you try to use it, no message is sent, but the user will mistakenly think they sent one. When there is no email address entered, that “Send Message” button should instead be hidden. And that’s what the code change above does.

    Thanks

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, i think that the best way to do that is to just make the fields Title and Email required in the contact form then users will not be able to submit it without properly filling all the fields.

    Thread Starter jnorell

    (@jnorell)

    Sorry, I see the confusion. I did not make the email address in the “Contact form” form optional, I made the email address in the “Create Adverts” form optional.

    The problem is not that users don’t provide their own email address when using the Contact Form, the problem scenario is: an anonymous user creates an ad without providing an email address (since I just made it optional), the ad is moderated and posted; another website user now views the ad, clicks the “Send Message” button, completes the form properly and hits Send. At this point, the second user expects to have sent a message to the first user, but since the first user didn’t provide an email address, nothing is actually sent.

    What I would like (and the above code does) is to hide the “Send Message” link when the first user (ie. the user who posted the ad) didn’t provide an email address. Ie. the contact form is useless with an empty adverts_email, so lets hide it.

    • This reply was modified 9 years ago by jnorell. Reason: clarify which form is being edited
    • This reply was modified 9 years ago by jnorell. Reason: clarify which form is being edited
    Plugin Author Greg Winiarski

    (@gwin)

    Hi, ooh i understand now :), it makes sense to hide the contact form if the user hasn’t provided his email address in [adverts_add] form and the code you pasted will be in next WPAdverts release, thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘optional adverts_email’ is closed to new replies.