Hi Stefan,
we use Version 1.8.3… so did we oversee something in the options?
-
This reply was modified 3 years, 8 months ago by
wvgdesign.
Hi @wvgdesign,
Apparently the example from the documentation is invalid. The filter should be a function, not a boolean result…
This should be valid:
add_filter(
‘statify__user_can_see_stats’,
function( $previous ) {
return $previous || current_user_can( ‘edit_others_pages’ );
}
);
$previous is the result of previously executed filters or – if none – the default result of Statify which is either true or false. Can be extended as needed.
Cheery,
Steafn
Hi Stefan,
thanks for your quick reply… we got an error in WP, please see screenshots here: https://imgur.com/a/5EmWK2x
Do we have to implement it into functions.php (child theme) in an amended way?
Thanks,
Andreas
Oh, I see. Copied some wrong quoting signs, so it is not a valid PHP string. Should be highlighted red in the editor and it obviously is not.
Correct: 'statify__user_can_see_stats'
Incorrect: ‘statify__user_can_see_stats‘
Same for both strings.
Hi Stefan,
sorry but… inserted this code
add_filter(
‘statify__user_can_see_stats’,
function( $previous ) {
return $previous || current_user_can( ‘edit_others_pages’ );
}
);
and get this message:
Deine PHP-Code-Änderungen wurden aufgrund eines Fehlers in Zeile 5 der Datei wp-content/themes/Impreza-child/functions.php zurückgesetzt. Bitte beheben und versuchen, erneut zu speichern.
syntax error, unexpected ”statify__user_can_see_stats” (T_CONSTANT_ENCAPSED_STRING), expecting ‘)’
Ausblenden
Yours: ‘
Mine: '
Different character.
It may look similar depending on the font, but is not the same.
Probably typed on some mobile device keyboard or modified by auto“correction“. Only one of them is a valid string delimiter in PHP.