• Resolved rothestar

    (@rothestar)


    Hi, I would like to import a grup of members and so it is working flawless.. but I have one problem, I would like to prevent the user from editing the member number on the user profile page… is it possible to write protect a field like the username is wrie protected??

    best regards
    Henrik

    • This topic was modified 8 years, 1 month ago by rothestar.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Javier Carazo

    (@carazo)

    @rothestar,

    No it can be done directly but yes, it could be done like a new develop.

    If you do not know how to do it, tell me and we do.

    Thanks!

    Thread Starter rothestar

    (@rothestar)

    got no idea how to do it yet, still learning… surfing the internet

    but something like putting () for on the meta title or []..

    ()=admin can edit
    []= nobody can edit, except with a new upload…

    just an idea..

    Plugin Author Javier Carazo

    (@carazo)

    It won’t be so simple…

    If you want to provide code this is ok or if not we can give you a premium support.

    Thread Starter rothestar

    (@rothestar)

    Found the solutions:

    In the active theme add the following to the functions.php

    It is possible to disable any input field at user profile. Let’s apply it to the ’email’ and ‘role’ fields, for example:

    add_action(‘admin_init’, ‘user_profile_fields_disable’);

    function user_profile_fields_disable() {

    global $pagenow;

    // apply only to user profile or user edit pages
    if ($pagenow!==’profile.php’ && $pagenow!==’user-edit.php’) {
    return;
    }

    // do not change anything for the administrator
    if (current_user_can(‘administrator’)) {
    return;
    }

    add_action( ‘admin_footer’, ‘user_profile_fields_disable_js’ );

    }

    /**
    * Disables selected fields in WP Admin user profile (profile.php, user-edit.php)
    */
    function user_profile_fields_disable_js() {
    ?>
    <script>
    jQuery(document).ready( function($) {
    var fields_to_disable = [’email’, ‘role’];
    for(i=0; i<fields_to_disable.length; i++) {
    if ( $(‘#’+ fields_to_disable[i]).length ) {
    $(‘#’+ fields_to_disable[i]).attr(“disabled”, “disabled”);
    }
    }
    });
    </script>
    <?php
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘write protect e meta field’ is closed to new replies.