Enable Edit For admin while on Front end read only metabox

Support MB Frontend Submission Enable Edit For admin while on Front end read only metaboxResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13726
    baraanajjar@gmail.com[email protected]
    Participant

    Hi Support
    i have form on front end as

    array(
                    'id' => 'your_phone',
                    'type' => 'text',
                    'required'   => true,
                    'readonly'  => true,
                    'name' => esc_html__( 'Your Phone' ),
                    'std' => $profile->user_info->user_phone_number,
                    'class' => 'col-md-6',
                    'placeholder' => esc_html__( 'Your Phone' ),
                ),

    i want this field to be edited by admin on backend while on frontend form should be readonly
    i am using frontend form plugin.
    thanks

    #13745
    Anh TranAnh Tran
    Keymaster

    You can modify the readonly attribute with the value like this:

    'readonly' => ! is_admin(),

    So, on the admin, it's true, on the front end - false.

    #13758
    baraanajjar@gmail.com[email protected]
    Participant

    Thanks for the tip. It is solved

    #41456
    Aravinda MondalAravinda Mondal
    Participant

    I am having a similar issue. I want the frontend form to be editable but on admin side, I want the fields to be 'readonly' . I tried this attribute: readonly = is_admin(). It is making the fields 'readonly' in both admin and frontend.

    #41458
    PeterPeter
    Moderator

    Hello Aravinda,

    You need to register the meta box and custom fields with code to use that logic. Please read more on the documentation https://docs.metabox.io/creating-fields-with-code/

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