Home Forums Plugin Support WP User Frontend Pro No Show Google Maps in author page

This topic is: resolved

This topic contains 10 replies, has 2 voices, and was last updated by  creatius 5 years, 10 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #4088

    creatius
    Participant
    Post count: 11

    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:

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

    < ?php wpuf_shortcode_map( 'map', $curauth->ID ); ?>

    Thanks.

    #4092

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #4094

    creatius
    Participant
    Post count: 11

    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 );
    }
    #4098

    creatius
    Participant
    Post count: 11

    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

    #4102

    Tareq Hasan
    Keymaster
    Post count: 2831

    are you sure that $curauth contains the user info?

    #4103

    creatius
    Participant
    Post count: 11

    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.

    #4106

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #4109

    creatius
    Participant
    Post count: 11

    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.

    #4114

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #4115

    creatius
    Participant
    Post count: 11

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

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

    #4136

    creatius
    Participant
    Post count: 11

    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 11 posts - 1 through 11 (of 11 total)

The topic ‘No Show Google Maps in author page’ is closed to new replies.