How I changed Google Maps to reflect user's Profile information
This is how I did it, quick and dirty.
First, I followed Seth's tutorial on adding the new phone number field to the "Poster" tab and "Profile" sections.
http://appthemes.com/forum/showthrea...g+phone+number (Great Tutorial!)
I then added more fields to generate a new address entry for the usermeta table.
I made some personal preference changes but for the most part, it's straight from his tutorial.
For example on Seth's tutorial under step 1, I added;
Code:
update_usermeta($user_ID, 'business_name', $_POST['business_name']);
update_usermeta($user_ID, 'profile_street', $_POST['profile_street']);
update_usermeta($user_ID, 'profile_city', $_POST['profile_city']);
update_usermeta($user_ID, 'profile_state', $_POST['profile_state']);
update_usermeta($user_ID, 'profile_zip', $_POST['profile_zip']);
update_usermeta($user_ID, 'phone', $_POST['phone']);
Ok, so now on to my temporary method of telling the google map to ignore the posting meta for the address only, and look at the users profile address if they choose to fill it in.
**This is on a 3.02 install. I am assuming that this can be done with child themes now but I have not upgraded to 3.03 just yet.
First I made a backup copy of sidebar-gmap.php.
Second I opened it in the Editor.
Find this line…(around line 13)
Code:
$gmaps_loc_txt = get_option('cp_gmaps_loc_txt');
I added some variables just below that line;
Code:
$author_street = get_the_author_meta('profile_street');
$author_city = get_the_author_meta('profile_city');
$author_state = get_the_author_meta('profile_state');
$author_zip = get_the_author_meta('profile_zip');
Then I found this line…(line 24 I think)
Original Line;
Code:
$make_address = get_post_meta($post->ID, 'cp_street', true) . ' ' . get_post_meta($post->ID, 'cp_city', true) . ' ' . //get_post_meta($post->ID, 'cp_state', true) . ' ' . get_post_meta($post->ID, 'cp_zipcode', true);
And I changed it to this…
Code:
$make_address = ($author_street) . ' ' . ($author_city) . ' ' . ($author_state) . ' ' . ($author_zip);
That's all I did. Now each post's map will show the address for the user from information entered only once by the user in their "Edit Profile" section.
Oh, I also removed the address fields from the posting forms. That way user won't see those as an option when posting an ad.
At the moment however, I still have to add the country option to both mods. I will do that when I work on a child-theme function for this.
Lastly, I'm a beginner Wordpress and ClassiPress user. Only had them for a few weeks so I have no doubt that there are better ways of doing what I did. So if any of you see a simpler way, please let me know. I've tested this and it all appears to be working fine. And this is across a
WP 3.0 network install. All sub sites show the user's address on the map no matter which section they post in.
Thanks,
TroyD