Skip to content

Instantly share code, notes, and snippets.

@cryptexvinci
Last active November 21, 2020 03:10
Show Gist options
  • Save cryptexvinci/d4ed4d84cd49f3208b40550f80e0c394 to your computer and use it in GitHub Desktop.
Save cryptexvinci/d4ed4d84cd49f3208b40550f80e0c394 to your computer and use it in GitHub Desktop.
Ultimate Member - Get custom field uploaded image url
<?php
/**
* Display custom field image url in Member Directory
* URL: https://wordpress.org/support/topic/get-uloaded-image-url/
*/
add_action( 'um_members_just_after_name', 'custom_function_tester_dir' );
function custom_function_tester_dir(){
// Get the filename
$image_filename = um_user( 'national_id' );
// Check if the file is there
if(!empty($image_filename)){
// Get the WordPress upload directory URL
$upload_dir = wp_upload_dir();
// Look in to Ultimate Member foler and construct the image URL
$image_url = esc_url( $upload_dir['baseurl'] . '/ultimatemember/' . um_user( 'ID' ) . '/' . $image_filename );
// Output the image
echo "<img src='$image_url'>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment