• Resolved mrruim

    (@mrruim)


    I know we can make some fields “Read Only”.
    But is there a way to make them read only to all users except for admins?

    I manage to made some fields (checkbox_list and text-area) read only with the following code but i can´t make them editable by admins. Once they are Read Only they are Read only for all users including admins…

    add_filter( ‘rwmb_my_field_1_html’, ‘prefix_input_readonly’ );
    add_filter( ‘rwmb_my_field_2_html’, ‘prefix_input_readonly’ );
    function prefix_input_readonly( $html )
    {
    return str_replace(
    array(
    ‘<textarea’,
    ‘<input’,
    ),
    array(
    ‘<textarea readonly’,
    ‘<input disabled’,
    ),
    $html );
    }

    Any help on this? Read only for all users but editable by admins?

    Thank you

    https://wordpress.org/plugins/meta-box/

Viewing 1 replies (of 1 total)
  • Plugin Author Anh Tran

    (@rilwis)

    You can simply add if ( ! current_user_can( 'manage_options' ) ) at the beginning of the callback function.

Viewing 1 replies (of 1 total)

The topic ‘Read only field except for admins’ is closed to new replies.