• smarta-brett

    (@smarta-brett)


    I am using WooCommerce for a clients website and have created an extra field called ”
    Staff Notes” and I would like it only to be visible when someone is a logged in user.

    Currently the WooCommerce is set to catalog mode and will be for quite some time – so there is no need for anyone to be logged in apart from site admins

    My clients wants to use the (soon to be hidden) new field to be notes for his staff that he does not want the public to see

    so to summarise – I want a field in a Woo Commerce product that can only be viewed if a user is logged in

    I have tried this CSS
    .staff_notes { display: none !important; }
    body.logged-in .staff_notes { display: inline-block !important; }

    but it does not seem to work

    …. any suggestions?

Viewing 1 replies (of 1 total)
  • Plugin Contributor sarkparanjothi

    (@sarkparanjothi)

    Sorry for the delay replay, try this in your template header section

    <?php
    $current_user = wp_get_current_user();
    if ( 0 == $current_user->ID ) {
        echo "<script> $( 'div[class*=wccpf-fields-group]' ).hide(); </script>";
    } else {
        echo "<script> $( 'div[class*=wccpf-fields-group]' ).show(); </script>";
    }
    ?>

    this for hide fields.

    if you want to remove fields:

    <?php
    $current_user = wp_get_current_user();
    if ( 0 == $current_user->ID ) {
        echo "<script> $( 'div[class*=wccpf-fields-group]' ).remove(); </script>";
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘show custom field to logged in user only?’ is closed to new replies.