No Show Google Maps in author page

This topic contains 10 reply and 2 voices, and was last updated by creatius 10 years, 11 months ago
Viewing 10 Posts - 1 through 10 (of 10 total)
Author Posts
May 23, 2013 at 7:29 pm 4088
creatius Hello, I need to integrate google maps, in the author's website (author.php). Added the option on the registration form but not displayed on the page of the author. Code: ID ); ?> Thanks.
May 23, 2013 at 9:18 pm 4092
Tareq Hasan Tareq Hasan

Hmm, thats interesting. It’ll not work for user profile. Currently this function only works posts, not users. So I’ll suggest one thing, see wpuf-functions.php line:663, you’ll found the function wpuf_shortcode_map. Replace with this code below:

So from now, you can use it like this: wpuf_shortcode_map_post( 'meta_key', $post_id ) for posts, wpuf_shortcode_map_user( 'meta_key', $user_id ) for users.

This modification will be coming with plugin in future update.

May 23, 2013 at 9:46 pm 4094
creatius creatius

Thanks!

I just try, added the following code at line 663, but still showing the map in the ocean.
Is that correct?

shortcode

<?php echo wpuf_shortcode_map_user( 'mapa', $user_id ); ?>

function wpuf_shortcode_map( $location, $post_id = null, $args = array() ) {
     
    // compatibility
    if ( $post_id ) {
        wpuf_shortcode_map_post( $location, $post_id, $args );
        return;
    }
 
    $default = array('width' => 450, 'height' => 250, 'zoom' => 12);
    $args = wp_parse_args( $args, $default );
 
    list( $def_lat, $def_long ) = explode( ',', $location );
    $def_lat = $def_lat ? $def_lat : 0;
    $def_long = $def_long ? $def_long : 0;
    ?>
 
    <div class="google-map" style="margin: 10px 0; height: <?php echo $args['height']; ?>px; width: <?php echo $args['width']; ?>px;" id="wpuf-map-<?php echo $meta_key; ?>"></div>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
 
    <script type="text/javascript">
        jQuery(function($){
            var curpoint = new google.maps.LatLng(<?php echo $def_lat; ?>, <?php echo $def_long; ?>);
 
            var gmap = new google.maps.Map( $('#wpuf-map-<?php echo $meta_key; ?>')[0], {
                center: curpoint,
                zoom: <?php echo $args['zoom']; ?>,
                mapTypeId: window.google.maps.MapTypeId.ROADMAP
            });
 
            var marker = new window.google.maps.Marker({
                position: curpoint,
                map: gmap,
                draggable: true
            });
        });
    </script>
    <?php
}
 
/**
 * Map shortcode for users
 *
 * @param string $meta_key
 * @param int $user_id
 * @param array $args
 */
function wpuf_shortcode_map_user( $meta_key, $user_id = null, $args = array() ) {
    $location = get_user_meta( $user_id, $meta_key, true );
    wpuf_shortcode_map( $location, null, $args );
}
 
/**
 * Map shortcode post posts
 *
 * @global object $post
 * @param string $meta_key
 * @param int $post_id
 * @param array $args
 */
function wpuf_shortcode_map_post( $meta_key, $post_id = null, $args = array() ) {
    global $post;
     
    if ( !$post_id ) {
        $post_id = $post->ID;
    }
     
    $location = get_post_meta( $post_id, $meta_key, true );
    wpuf_shortcode_map( $location, null, $args );
}
May 23, 2013 at 11:25 pm 4098
creatius creatius

Hello again, I also noticed that the author’s custom fields shown in the entries. Used this code:

single.php

<?php
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
?>

<?php echo get_user_meta( $curauth->ID, 'telefono', true ); ?>

Thanks

May 24, 2013 at 9:41 am 4102
Tareq Hasan Tareq Hasan

are you sure that $curauth contains the user info?

May 24, 2013 at 9:46 am 4103
creatius creatius

I think not, because it does not show any results. As I can see user data within a post?

By the way the map in the profile does not work, you can review the above code please?

Thank you very much.

May 24, 2013 at 9:56 am 4106
Tareq Hasan Tareq Hasan

So you are saying <?php echo get_user_meta( $curauth->ID, 'telefono', true ); ?> works, not the map?

May 24, 2013 at 10:11 am 4109
creatius creatius

The map you want to display on the author page. I tried the above code does not work. Displays the map but does not show the address. (author.php)

In single.php page need to show custom fields author, but shows no result with the previous variable.

May 24, 2013 at 10:42 am 4114
Tareq Hasan Tareq Hasan

I am confused with the answer. If the $curauth doesn’t contain the value, there is no way the map can be shown. So make sure you are getting the user id correctly first.

May 24, 2013 at 10:45 am 4115
creatius creatius

To display the map in author.php put the following code:

May 24, 2013 at 12:29 pm 4136
creatius creatius

Sorry, made ​​two queries in the same post, I confused. The problem that I have, which added wpuf-functions.php code and does not work with the following shortcode

<? php echo wpuf_shortcode_map_user ('map', $ user_id);?>

thanks

Viewing 10 Posts - 1 through 10 (of 10 total)