• Hi,I have a questions as the Title.
    How to let Different Users see and edit different Custom Field?
    for example:
    user1 can input customfild “price” “100”,Only!
    power-user1 can input additional customfild1 “discount” “20%”.

    How?Plz help me.

    byw:I try “role manager”,It can add “Custom Capabilities” for different users,But I can not let the “Custom Capabilities” define different custom fields.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hmm. This sounds like it could be a tough one and would require some fairly intensive getting down and dirty with code.

    I think you’d need to use something like:

    https://www.ads-software.com/extend/plugins/custom-field-template/

    But you’d need to get into the code base and modify how it displays.

    Assuming user1 is set with an access level of say 5 in role manager, and power-user1 is level 6 then you’d be able to use something like:

    <?php
    global $userdata;
    get_currentuserinfo();
    $level = $userdata->user_level;
    if ($level = 5) {
    // Show one custom field template
    } elseif ($level >= 6){
    // Show extended custom field template
    }
    ?>

    This plugin is really quite nice – but I’d say if you asked the plugin creator whether something like this would be possible he might have a better idea – it could even be something he’d see fit to add to the plugin (eg being able to set each template as assignable to a user level).

    Thread Starter mengfanchungmailcom

    (@mengfanchungmailcom)

    Thx a lot!
    and the plugin is great 2,I have already use a plugin “custom field gui”,and it can let me so something some but lite.
    I will think about what u post,but as I am a noob in php,it is hard to me.

    Alexleonard said good advice, a good approach. I agree to try that, including asking the plugin author if he knows a way.

    By the way, the plugin Custom Field Template, is an update on the older plugin “rc:custom field gui”. It is the same, only better ??

    In WP 2.8.X you should be able to make these changes in “wp-admin/includes/template.php”. Take a look at the function “_list_meta_row” around line 2282. On line 2293 you should see something like this:

    if ('_' == $entry['meta_key'] { 0 })
    $style .= ' hidden';

    This is saying if there is an underscore character at the beginning of the meta key then hide it. Example would be “_customfield_price”. This is done because WP already has several custom fields it doesn’t want you to see and it designates them by putting an underscore at the beginning of their name. Depending on how detailed you want to get, modify line 2293-2294 to look something like this:

    global $userdata;
    get_currentuserinfo();
    $level = $userdata->user_level; //gets user level

    if ('_' == $entry['meta_key'] { 0 } || $level < 10 && 'customfield_discount' == $entry['meta_key'] )
    $style .= ' hidden';

    This will hide a meta field name “customfield_discount” if the user is not the admin.

    I forgot to mention you will also need to modify around line 2366 to prevent the meta key from showing in the drop down menu. Look around 2366 for something like this:

    foreach ( $keys as $key ) {
    $key = attribute_escape( $key );
    echo "\n<option value='$key'>$key</option>"
    }

    Add this code to prevent it from showing in the drop down list under “Add New Custom Field”.

    global $userdata;
    get_currentuserinfo();
    $level = $userdata->user_level; //gets user level

    foreach ( $keys as $key ) {
    $key = attribute_escape( $key );
    if($key == 'customfield_discount' && $level < 10)
    {//do nothing}
    else
    {echo "\n<option value='$key'>$key</option>";}
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Different User see Different Custom Fields,How?’ is closed to new replies.