Reputation: 73
I am using this plugin for my Wordpress site: https://wordpress.org/plugins/user-registration/
To display for example, the users country they choose - this is the simple code you can use:-
<?php global $current_user; echo $current_user->user_registration_country; ?>
This displays the users country they selected on registration. I now want to display their photo they uploaded, so I am doing the following:-
<?php global $current_user; echo $current_user->user_registration_upload_picture; ?>
However this is only showing the ID of the image within the frontend of the site.
Could someone please help, in how I can convert the ID to display the image url?
Thank you!
Upvotes: 0
Views: 147
Reputation: 4774
The ID you're getting is probably the ID of an attachment. You can find the image information using wp_get_attachment_image_src
, then display it:
$image_attributes = wp_get_attachment_image_src( $current_user->user_registration_upload_picture );
if ($image_attributes) : ?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
Upvotes: 1