Site icon Hip-Hop Website Design and Development

Cover customized fields by person’s function

I’ve tried studying all of the questions on this matter, and configured the code to suit my wants, however can not seem to get it to work. That is the code I’ve now:

operate my_exclude_custom_fields( $protected, $meta_key, $person ) {

    $person = wp_get_current_user();
    if ( in_array( 'udlejer', (array) $user->roles ) ) {
        if ( in_array( $meta_key, array( 'e mail', 'textual content' ) ) ) {
            return true;
        }
    }

    return $protected;
}
add_filter( 'is_protected_meta', 'my_exclude_custom_fields', 10, 2 );

It does not make any change. Although I am logged in with one other function than udlejer, I can nonetheless see these customized fields in front-end.

The customized fields are on a product web page created by WooCommerce. Do I then want to incorporate extra to the code then? Hope you guys may also help!