Get username from url into shortcode

Web site is a wordpress site with user-pro plugin.

authors page slug as

I added this code to userpro index.php to get username from slug .

function func_print_username($username) {
    global $query_string;
    if($query_string != 'pagename=profile') {
        $patterns = '/(w+)=(w+)&(w+)=/i';
        $username = preg_replace($patterns, '', $query_string);
    } else {
        global $current_user;
        $current_user = wp_get_current_user();
        $username = $current_user->user_login;

    return trim($username);

    return "education= { trim$username[education] }";
add_shortcode('education', 'func_print_username');

I have a shortcode as [education="username"].
It works manually [education="john-doe"]

I want to get username into my shortcode on user profile page

<?php echo do_shortcode('[education="username"]'); ?>

But it’s not working. What am I missing ?


Source: shortcode

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.