This topic has 4 replies, 2 voices, and was last updated 7 years by Kieran_SQ.

  • Author
  • #175902
     jackbean
    Participant

    Hello,

    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

     

     

     

     

    Attachments:
    You must be logged in to view attached files.
    #175904
     jackbean
    Participant

    Hello 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

    #175905
     Kieran_SQ
    Moderator

    Hi,

    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 CODE
    ini_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 solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #175908
     jackbean
    Participant

    Thank 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

    #175910
     Kieran_SQ
    Moderator

    You’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

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?