• I tried to use the shortcode on a custom template page but it shows all the info like I posted [something] It doesnt make the shortcode conversion.

    tried this as well and nothing:

    <?php
      $user = get_user_by('slug', $author_name);
      echo get_wp_user_avatar($user->ID, 96);
    ?>

    [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.]

    https://www.ads-software.com/plugins/wp-user-avatar/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter Theopt

    (@theopt)

    https://www.dawnsource.com/display/?id=1

    you can check it here on the bottom, its a custom comment system I made and I was trying to get the avatar there.

    Did you place the shortcode directly into your PHP file? If so, you have to place it in like this:

    <?php echo do_shortcode('[avatar]'); ?>

    The code you’ve quoted would also only give you the avatar on an Author Page.

    Try this code instead, replacing 32 with whatever size you’d like to use:

    <?php echo get_wp_user_avatar($comment, 32); ?>

    Thread Starter Theopt

    (@theopt)

    tried both. the problem is the SCR isnt being loaded.

    this is the inspection:

    <img src=”” width=”” height=”” alt=”Theopt” class=”avatar avatar-40 wp-user-avatar wp-user-avatar-40 alignleft photo”>

    but on the theme comments avatars are working ??

    Would you mind posting the entire code block for your comments template? The img code is probably coming out that way because it’s calling for the wrong attachment ID.

    Thread Starter Theopt

    (@theopt)

    <?php echo do_shortcode(‘[avatar user=$name size=”40″ align=”left” ]’); ?>

    but get_avatar was working before.

    Thread Starter Theopt

    (@theopt)

    oh, you wanted from wordpress comments, where can I find that?

    I was under the impression that you made a custom comments template? However, from your example, I think this should be rewritten as:

    <?php echo do_shortcode('[avatar user='.$name.' size="40" align="left" ]'); ?>

    You should also check that you are passing either the user ID or username to $name.

    Thread Starter Theopt

    (@theopt)

    No, Im making a comment system that uses the user avatar but its not for wordpress posts, its for a wordpress custom page. But I think I should had used the wordpress comments in the first place xD but anyway, that code is giving me the same output ??

    Thread Starter Theopt

    (@theopt)

    Well using <?php comments_template()?> wont work on that pages so I guess I cant really use wordpress comment system because the comments will go to display page and wont be distributed to display/id=x. Anyway, where can I check the comments_template php file to see how they are doing there? because the other solution ain’t working :\

    I’m not sure I follow what it is that you’re doing, but you mentioned that get_avatar was working for you? Perhaps you can just revert to the comments template provided in your theme?

    Thread Starter Theopt

    (@theopt)

    Well, get avatar was working. but I needed your plugin because I left vbulletin so I dont have any sort of avatars for users atm. But wordpress comments are working and they do have avatar. I was making a comment system for a custom tool. The get_avatar was working there, but its not working now.

    Thread Starter Theopt

    (@theopt)

    I’ve reworked the code a bit, now it only shows default avatar image for users that didnt set a custom avatar.

    https://www.dawnsource.com/display/?id=1

    why is that?

    I still think it’s a problem with the wrong user ID being sent to the avatar code. Could you post the new code that you’re using?

    Thread Starter Theopt

    (@theopt)

    Well I think that but it doesnt make much sence, this is how im getting user id:

    $current_user = wp_get_current_user();
    $user = $current_user->user_login;
    $idaccount = $current_user->ID;

    this is how im getting the ID and using them when I need to fill new comments for instance. then I put them in the DB so I guess if anything is wrong is there.

    this is the output of the comments:

    while($row=mysql_fetch_array($sql))
            {
            $name=$row['name'];
    		$id=$row['Id_user'];
            //$email=$row['com_email'];
            $comment_dis=$row['body'];
    
            //$lowercase = strtolower($email);
            //$image = get_avatar( $id , 40 );
            ?>
    		<li class="panel" style="margin:10px; list-style-type: none;">
            <?
    		  echo get_wp_user_avatar($id, 40);
    		?>
            <span class="com_name"> <?php echo $name; ?></span> <br />
    		<?php echo $comment_dis; ?></li>
        	<?php
    		}
    		?>

    Thread Starter Theopt

    (@theopt)

    I’ve inserted my id from the mysql table manually, and now shows that man in the hat instead of my custom avatar. so im actually requesting the ID wrongly ?? u know why?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Shortcode not working’ is closed to new replies.