-
Author
-
October 7, 2017 at 17:42 #175902
jackbean
ParticipantHello,
I used the “kleo_bp_replace_placeholders_extra” function from Kleo support page to put logged in user’s ID in the primary menu. The function is defined here:
https://archived.seventhqueen.com/kleo/article/get-and-use-logged-in-username-variable-in-menu
The function is working for me, but is generating the error message:
“PHP Warning: Missing argument 2 for kleo_bp_replace_placeholders_extra() in /hermes/bosnaweb17a/b1766/ipg.prohrweborg/wp-content/themes/kleo-child/functions.php on line 18 “
Here’s the function’s call line:
function kleo_bp_replace_placeholders_extra( $output, $initial_output )
so it does seem that the argumentĀ $initial_outputĀ Ā is not defined in the function, therefore causing the error message.
This error message is really causing problem for me because it appears on the top of the website… please see the attached doc.
Thank you for your help!
JB
October 7, 2017 at 17:50 #175904jackbean
ParticipantHello again,
So I just tried to just delete the second argument that was not defined in the function, and the error seemed to go away.
So please let me know your thoughts on if I should just delete the second argument and won’t cause other problems.
Thank you.
JB
October 7, 2017 at 17:54 #175905Kieran_SQ
ModeratorHi,
Sorry to hear about the issues you have faced with this snippet, please try the below instead and let me know if that works for you.
COPY CODE// Show username in menu item 20171007 function kleo_bp_replace_placeholders_extra ( $output ) { if ( strpos( $output, '##username##' ) !== false ) { if ( ! is_user_logged_in() ) { return ''; } $current_user = wp_get_current_user(); $username = $current_user->user_login; $output = str_replace('##username##', $username, $output); } return $output; } add_filter('walker_nav_menu_start_el', 'kleo_bp_replace_placeholders_extra');If you no longer wish to see php warnings and errors printed on the frontend (for production/live sites) please edit wp-config.php and replace
define('WP_DEBUG', false);with
COPY CODEini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG', false); define('WP_DEBUG_DISPLAY', false);Thanks,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionOctober 7, 2017 at 18:08 #175908jackbean
ParticipantThank you Kieran!
So your new function indeed just had the undefined argument removed. Thank you for the confirmation on how to fix the error.
Your other tips on how to suppress php warnings and errors are very helpful too! I will keep them in mind for future use.
Thanks very much!!
JB
October 7, 2017 at 18:10 #175910Kieran_SQ
ModeratorYou’re welcome JB.
Have a great day,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Bugs & Issues’ is closed to new topics and replies.