0

I have problems with this piece of code. Wordpress throws me this message:

Warning: Use of undefined constant auction_mask_displayname - assumed 'auction_mask_displayname' (this will throw an Error in a future version of PHP)

Code:

add_filter( 'woocommerce_simple_auctions_displayname', auction_mask_displayname );
function auction_mask_displayname( $displayname ) {
        if ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
                return $displayname;
        } else {
            $length      = strlen( $displayname );
            $displayname = $displayname[0] . str_repeat( '*', $length - 2 ) . $displayname[ $length - 1 ];
        }

        return $displayname;

    }
FoggyDay
  • 11,962
  • 4
  • 34
  • 48
Enrique Da
  • 11
  • 2
  • This is apparently a WordPress plugin. The second argument should be quoted: `add_filter( 'woocommerce_simple_auctions_displayname','auction_mask_displayname');`. See the WP docs for an example: https://developer.wordpress.org/reference/functions/add_filter/ – FoggyDay Apr 19 '20 at 19:50

1 Answers1

2

Add quotes around auction_mask_displayname in the first line

See also What does the PHP error message "Notice: Use of undefined constant" mean?

astax
  • 1,769
  • 1
  • 14
  • 23