Shortcode displays user data/info on one page, but admin info on another?

I had someone create a shortcode for me to display users name & contact info etc.
The shortcode seems to work on some pages but on others it shows the admins info instead of the users info.
Here is one of the sites and on this page the shortcode shows the users info correctly:
http://evantage360.com/chanyevans/backoffice/
My about us & contact pages work fine as well.

Now when I create a new page and use the same shortcode [lmn_user_info] it is showing the super admins data:
http://evantage360.com/chanyevans/test/

I will post the shortcode below if that helps, I am not sure how much of this is related but if someone could point me in the right direction on how to troubleshoot this I would appreciate it.
I paid 2 different people to create this shortcode but it seems the people I find disappear after a few weeks or would go back to them for help :slight_smile:

add_shortcode('lmn','lmn_shortcode_func');

function lmn_shortcode_func($options){

	$extra_fields = array(
		'first_name' => 'First Name',
		'last_name' => 'Last Name',
		'address_1' => 'Address 1',
		'address_2' => 'Address 2',
		'city' => 'City',
		'state' => 'State',
		'zipcode' => 'Zipcode',
		'phone' => 'Phone'
	);
	$current_field = $options['field'];
	$blog_id = get_current_blog_id();
	$mail = get_blog_option($blog_id, 'admin_email');
	$user_from_email = get_user_by('email', $mail);
	$user_id = $user_from_email->ID;
	$value = get_user_meta($user_id, $current_field, true);
	ob_start();
	?>

	<?php
		$output = ob_get_clean();
		if($value){
			echo $extra_fields[$current_field].': '.$value.'<br />';
		}
		return $output;
}

// here are the shortcodes

add_shortcode( 'lmn_user_info' , 'z_get_current_info' );
function z_get_current_info(){
	$mail = get_the_author_meta('user_email');
	$user_display_name = get_the_author_meta('display_name');
	$user_fname = get_the_author_meta('user_firstname');
	$user_lname = get_the_author_meta('user_lastname');
	$user_phone = get_the_author_meta('phone');
	$user_zipcode = get_the_author_meta('zipcode');
	$user_address = get_the_author_meta('address_1');
	$user_city = get_the_author_meta('city');
	$user_state = get_the_author_meta('state');
	$user_sitename = get_site_url();
    return '<ul class="lmn_user_info lmn_user_info_list"><li>username : ' . $user_display_name . '</li><li> Name : ' . $user_fname . '<span> ' . $user_lname . '</span></li><li> Site : ' . $user_sitename . '</li><li> email : ' . $mail . '</li><li> phone : ' . $user_phone . '</li><li> address : ' . $user_address . '</li><li> city : ' . $user_city . '</li><li> state : ' . $user_state . '</li><li> zipcode : ' . $user_zipcode . '</li></ul>';
}

add_shortcode( 'lmn_user_username' , 'z_get_current_username' );
function z_get_current_username( $atts ){
	$user_display_name = get_the_author_meta('display_name');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_username">' . $text . '' . $user_display_name . '</span>';
}
/*
add_shortcode( 'user_name' , 'z_get_current_name' );
function z_get_current_name( $atts ){
	$user_fname = get_the_author_meta('user_firstname');
	$user_lname = get_the_author_meta('user_lastname');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_fname">' . $text . '' . $user_fname . '</span><span class="lmn_user_lname"> ' . $user_lname . '</span>';
}
*/

add_shortcode( 'user_name' , 'z_get_current_name' );
function z_get_current_name( $atts ){
$user_id = get_current_user_id(); /*Added by George*/
$user_fname = get_the_author_meta('user_firstname', $user_id);
$user_lname = get_the_author_meta('user_lastname', $user_id);
extract( shortcode_atts( array(
'text' => null,
), $atts ) );
return '<span class="lmn_user_info lmn_user_fname">' . $text . '' . $user_fname . '</span><span class="lmn_user_lname"> ' . $user_lname . '</span>';
}

add_shortcode( 'user_email' , 'z_get_current_email' );
function z_get_current_email( $atts ){
	$user_mail = get_the_author_meta('user_email');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_email">' . $text . '' . $user_mail . '</span>';
}

add_shortcode( 'user_phone' , 'z_get_current_phone' );
function z_get_current_phone( $atts ){
	$user_phone = get_the_author_meta('phone');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_phone">' . $text . '' . $user_phone . '</span>';
}

add_shortcode( 'user_address' , 'z_get_current_address' );
function z_get_current_address( $atts ){
	$user_address = get_the_author_meta('address_1');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_address">' . $text . '' . $user_address . '</span>';
}

add_shortcode( 'user_city' , 'z_get_current_city' );
function z_get_current_city( $atts ){
	$user_city = get_the_author_meta('city');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_city">' . $text . '' . $user_city . '</span>';
}

add_shortcode( 'user_state' , 'z_get_current_state' );
function z_get_current_state( $atts ){
	$user_state = get_the_author_meta('state');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_state">' . $text . '' . $user_state . '</span>';
}

add_shortcode( 'user_zipcode' , 'z_get_current_zipcode' );
function z_get_current_zipcode( $atts ){
	$user_zipcode = get_the_author_meta('zipcode');
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_zipcode">' . $text . '' . $user_zipcode . '</span>';
}

add_shortcode( 'lmn_user_siteurl' , 'z_get_current_siteurl' );
function z_get_current_siteurl( $atts ){
	$user_sitename = get_site_url();
	extract( shortcode_atts( array(
        'text' => null,
    ), $atts ) );
    return '<span class="lmn_user_info lmn_user_siteurl">' . $text . '' . $user_sitename . '</span>';
}
  • Michael Bissett

    Hey @George, hope you're doing well today! :slight_smile:

    Having access to the subsite itself would most likely confirm this, but I get the feeling that the pages you mentioned (the Backoffice, about us & contact pages) were created by the "chany_2" user. If so, then the get_the_author_meta function is getting the details you're wanting there, because that user was the author of those pages.

    However, that test page being created by you (the Super Admin), you're the author of that page, and as such, your details would be shown here.

    This making sense so far, or am I off the mark somewhere here? :slight_smile:

    Please advise,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.