*

mwindey

  • *****
  • 482 posts
Readonly fields in contact on item page
« on: May 08, 2021, 12:01:22 PM »
Hello, for logged in users there is the contact form on the item.php page. If a logged in user wants to send a message, their name and email address is entered automatically in the input fields. However, I want to make these fields read only because i don't want them to use another email address other than the one they registered with. I'm not using unregistered users so there is no need to change name and address in the fields.
 The code to change I suspect is this
                   
Code: [Select]
   <?php ContactForm::your_name(); ?>
                    <label><?php _e('Name''veronika') ; ?></label>
                    </div>

                    <div class="row second">
                      <?php ContactForm::your_email(); ?>
                      <label><span><?php _e('E-mail''veronika'); ?></span><span class="req">*</span></label>
                    </div>
<?php ?>
                    <div class="row full">
                      <?php ContactForm::your_message(); ?>
                    </div>

                    <?php osc_run_hook('item_contact_form'osc_item_id()); ?>
                    <?php osc_show_recaptcha(); ?>
                    <?php osc_run_hook("anr_captcha_form_field"); ?>
But how do I get started? Seems simple and will probably be simple, but my idea doesn't work :-) Anyone an idea? Thanks
« Last Edit: June 06, 2021, 05:57:36 PM by mwindey »

*

MB Themes

Re: Readonly fields in contact on item page
« Reply #1 on: May 09, 2021, 11:51:08 AM »
@mwindey
Easiest way is to achieve this using jQuery.
Something like this should work:
Code: [Select]
<?php if(osc_is_web_user_logged_in()) { ?>
  <script>
    $(document).ready(function() {
      $('form[name="contact_form"] input[name="yourName"], form[name="contact_form"] input[name="yourEmail"]').attr('readonly', true);
    });
  </script>
<?php ?>


  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 482 posts
Re: Readonly fields in contact on item page
« Reply #2 on: May 09, 2021, 07:34:03 PM »
@MB Themes
Thanks for the help on this ... It works perfectly the way I wanted it to. super satisfied customer here :-)

*

MB Themes

Re: Readonly fields in contact on item page
« Reply #3 on: May 09, 2021, 09:46:31 PM »
Cool  :)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots