Hi,
I’m using the following snippet to add a link to the users name in the message box.
add_filter( 'fep_filter_user_name', function( $name, $id ){
$authordata = get_userdata( fep_get_message_field( 'mgs_author' ) );
if( in_array( 'employer', $authordata->roles ) ){
$name = '<a href="/jobs/'. fep_get_userdata( $id, 'user_nicename', 'id' ) . '/" target="_blank" rel="noreferrer noopener">' . $name . '</a>';
}
return $name;
}, 10, 2);
However, I’m getting the below error codes when in debug mode. Is there a fix for this?
Notice: Trying to get property ‘roles’ of non-object in /www/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()’d code on line 3 Warning: in_array() expects parameter 2 to be array, null given in /www/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()’d code on line 3
Thanks