• Resolved finchmgn

    (@finchmgn)


    How i can display first name and last name in “Labels Edit” add-on, use variables like %1$s, %2$s?
    Example:
    Label to Edit: You are currently logged in as %1$s. %2$s
    New label: Hi, “first name”. %2$s

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    I presume that you would like to modify the “You are currently logged in as %1$s. %2$s” string.

    You will need to use some custom code:

    1. Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db

    2. Add the following code to the end of it:

    /*
     * Filter the logged in message from the PB login form to display the first name and last name instead of username
     * The first name and last name links to Edit Profile
     */
    
    add_filter('wppb_login_message', 'wppbc_custom_logged_in_msg_3', 10, 3);
    function wppbc_custom_logged_in_msg_3($logged_in_message, $user_id, $display_name){
        $user = get_userdata ($user_id);
        $first_name = $user->first_name;
        $last_name = $user->last_name;
        $user_url = '<a href="https://www.yoursite.com/edit-your-profile" class="wppb-author-url" title="'. $first_name . $last_name .'">'. $first_name .' '. $last_name . '</a>';
        $logout_url = '<a href="'.wp_logout_url( $redirectTo = wppb_curpageurl() ).'" class="wppb-logout-url" title="'.__( 'Log out of this account', 'profilebuilder' ).'">'. __( 'Log out', 'profilebuilder').' &raquo;</a>';
        return '<p class="wppb-alert">' . sprintf(__( 'Hi, %1$s. %2$s', 'profilebuilder' ), $user_url, $logout_url ) . '</p><!-- .alert-->';
    }

    3. Replace “https://www.yoursite.com/edit-your-profile” with the URL of your Edit Profile page

    Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

    Let me know if it works.

    Best regards,

    Thread Starter finchmgn

    (@finchmgn)

    Thank you very-very much, Teodor! It works fine! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Variables with numbers like 1, 2, 3 (%1$s, %2$s)’ is closed to new replies.