Advertisement:

Author Topic: Make mobile number field uneditable in update form  (Read 166 times)

moinuddin

  • Full Member
  • ***
  • Posts: 102
Make mobile number field uneditable in update form
« on: June 28, 2019, 10:50:26 am »
Hi,

Is there any way where i can make mobile number field uneditable in update form ..i want that user is able to change all information except mobile number.

Thanks in advance.


moinuddin

  • Full Member
  • ***
  • Posts: 102
Re: Make mobile number field uneditable in update form
« Reply #1 on: June 29, 2019, 04:28:45 pm »
 <div class="control-group">
                <label class="control-label" for="phoneMobile"><?php _e('Cell phone', 'bender'); ?></label>
                <div class="controls">
                    <?php UserForm::mobile_text(osc_user()); ?>
                </div>
            </div>

the above code is displayed in bender theme..

i have found a solution ..but that is in modern theme.

https://forums.osclass.org/general-help/make-username-on-update-my-profile-non-editable/


any one can help me ??

thanks in advance

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Make mobile number field uneditable in update form
« Reply #2 on: June 30, 2019, 01:23:36 am »
Hello!

This is default code in oc-content/themes/user-profile.php:

Code: [Select]
            <div class="control-group">
                <label class="control-label" for="phoneMobile"><?php _e('Cell phone''bender'); ?></label>
                <div class="controls">
                    <?php UserForm::mobile_text(osc_user()); ?>
                </div>
            </div>

We can check if osc_user() array contains a phone number, if it does we can make field uneditable by changing <?php UserForm::mobile_text(osc_user()); ?> with custom input to avoid core changes.

Code: [Select]
            <div class="control-group">
                <label class="control-label" for="phoneMobile"><?php _e('Cell phone''bender'); ?></label>
                <div class="controls">
                    <?php if(@osc_user()['s_phone_mobile'] != '') { ?>
                        <input id="s_phone_mobile" type="text" name="s_phone_mobile" value="<?php echo osc_user()['s_phone_mobile']; ?>" disabled>
                    <?php } else { ?>
                        <?php UserForm::mobile_text(osc_user()); ?>
                    <?php ?>
                </div>
            </div>

Regards.

moinuddin

  • Full Member
  • ***
  • Posts: 102
Re: Make mobile number field uneditable in update form
« Reply #3 on: June 30, 2019, 02:10:55 am »
Ill check it and will let you know in short time...thanks for the solution.

moinuddin

  • Full Member
  • ***
  • Posts: 102
Re: Make mobile number field uneditable in update form
« Reply #4 on: July 04, 2019, 10:28:25 am »
hi patrickFromCroatia,

thanks for the solution..but it shows the uneditable field with number ..but when we make changes in the form with the other field ..then the mobile number field does gets blank..i.e if we make updates in other field then by default the value sent in mobile field is blank ..and if we see again the user account form again after changes then it shows blank mobile field

any solutions for this ??

thanks in advance .


moinuddin

  • Full Member
  • ***
  • Posts: 102
Re: Make mobile number field uneditable in update form
« Reply #5 on: July 04, 2019, 11:21:57 am »
got it , we can use readonly property instead of disabled.as disable will not send values to server and read only would do..

thanks patrickFromCroatia , this problem is solved because of you.