Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter paul.aston

    (@paulaston-1)

    Okay, ignore my previous post, that was a bad case of premature ecodeulation.

    The code below is a bit of a work around, but it works. If you use WPUFP to register a user, you can use the googlemap feature to pick an address. This will then output to a custom field (in this case “geo_address”).
    The problem is that this is in user_meta and geo mashup wont read it. However, geo mashup WILL read geo_latitude & geo_longitude in user_meta. This code will take the lat/long string in geo_address, split it and save it into geo_lat/long

    $blogusers = get_users( $args ); // for args see codex
    
    if ($blogusers) {
      foreach ( $blogusers as $bloguser ) {
    	$user = get_userdata($bloguser->user_id);
        $user_location = get_the_author_meta('geo_address', $bloguser->ID );
    	$pieces = explode (',', $user_location );
    
    	$has_meta = get_user_meta ( $bloguser->ID, 'geo_latitude', $pieces [0], true);
    	if ($user_location && ! $has_meta) add_user_meta( $bloguser->ID, 'geo_latitude', $pieces [0]);
    
    	$has_meta = get_user_meta ( $bloguser->ID, 'geo_longitude', $pieces [1], true);
    	if ($user_location && ! $has_meta) add_user_meta( $bloguser->ID, 'geo_longitude', $pieces [1]);
    
      }
    }

    It’s a bit hacky, but it solves a problem I’ve been fiddling with for DAYS.

    Thread Starter paul.aston

    (@paulaston-1)

    I started working on a workaround for this, and have put together a function that takes the data from from the user_meta and adds it to the post_meta of the page displaying the map:

    <?php 
    
    $blogusers = get_users( $args ); // for args see codex
    
    if ($blogusers) {
      foreach ( $blogusers as $bloguser ) {
        $user_location = get_the_author_meta('geo_address', $bloguser->ID );
        $has_meta = get_post_meta(463, 'geo_mover', true);
        if ($user_location && ! $has_meta) add_post_meta( 22, 'geo_mover', $user_location);
      }
    }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    It works pretty well (although there is a duplicate issue), but as I’m testing it, with geo_mover in the custom field box, the displayed map only shows one marker

Viewing 2 replies - 1 through 2 (of 2 total)