Hi, try the following hook. It will add a new userdata field in the uploaded file with the uploaded image path.
if (!function_exists('wfu_before_file_check_handler')) {
function wfu_before_file_check_handler($changable_data, $additional_data) {
$item = array(
"type" => "text",
"label" => "Path",
"labelposition" => "left",
"required" => false,
"donotautocomplete" => false,
"validate" => false,
"typehook" => false,
"hintposition" => "inline",
"default" => "",
"data" => "",
"group" => "",
"format" => "",
"occurrence" => 1,
"value" => $changable_data["file_path"]
);
array_push($changable_data["user_data"], $item);
return $changable_data;
}
add_filter('wfu_before_file_check', 'wfu_before_file_check_handler', 10, 2);
}
Regards
Nickolas
Nickolas – thank you, but I realized this morning this won’t work for what I am trying to do. The wfu_userdata table doesn’t list the user’s ID so I have no way to query a specific user. Plus, the wfu_userdata table doesn’t reflect when a site admin deletes a user’s images. So, I am now trying to get the same information using the native WP posts table, but I’m still having a bit of trouble. It returns the user’s uploaded images, but also additional images that have nothing to do with that particular user. I am wondering how to make this query more specific so that only images uploaded by a specific user using your plugin will be returned. I am studying the posts table but I am not seeing any field that would be specific to your plugin.
$blogusers = get_users();
foreach ( $blogusers as $user ) {
$user_id = $user->ID;
$args = array(
‘post_author’ => $user_id,
‘post_type’ => ‘attachment’,
‘post_status’ => ‘inherit’
);
$query = new WP_Query( $args );
if ( $query ->have_posts() ) {
$img_string = ‘<div id=”user-gallery”>’;
while ( $query->have_posts() ) : $query->the_post();
$img_string .= get_the_title() . ‘
‘;
endwhile;
$img_string .= ‘</div>’;
} else {
// echo ‘no photos uploaded by ‘ . $user_id;
}
wp_reset_postdata();
} // end FOR loop
Nickolas- I got my results working using WP_Query. My arguments were wrong. I needed to use ‘author’ not ‘post_author’. So I have what I need! Thanks for a great plugin.