I've written a simple plugin that displays Business Names of users based on a zip code ($zip) that they have entered during registration. This information needs to be displayed to people that have not logged in.
The data is taken from the wp_usermeta table. I'm using a shortcode to display the output of the function. When I use "echo", it works but the output is above my content. I want it below. When I use "return", the output is below but it only displays one name and I know there are three.
Here's my code for both the shortcode and business name function.
function list_business_info_register_shortcodes(){
add_shortcode('list-business-info', 'list_business_info_function');
}
add_action( 'init', 'list_business_info_register_shortcodes');
function list_business_info_function()
{
$zip = "553031234";
$result = mysql_query("SELECT user_id FROM wp_usermeta WHERE meta_key='rpr_9-digit_zip_code' AND meta_value=$zip");
while ($row = mysql_fetch_array($result))
{
$userid = $row['user_id'];
$result2 = mysql_query("SELECT meta_value FROM wp_usermeta WHERE meta_key='rpr_business_name' AND user_id=$userid");
while ($row2 = mysql_fetch_array($result2))
{
$busname = $row2['meta_value'];
return $busname;
}
}
}
Thanks for your help