Support » Plugin: WordPress File Upload » Add filepath to wfu_userdata table?

  • Resolved justmigrating

    (@justmigrating)


    Is there a hook I can use to add the uploaded image filepath to the wfu_userdata table? The filepath is in the wfu_log table, but since the log can be cleared by my client, I would prefer not to use wfu_log for my query. I am using the filepath field to display a site user’s uploaded images on a page programmatically. Plus, the wfu_userdata table already has the image caption. Having the filepath in that table would really simplify my query. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nickboss

    (@nickboss)

    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

    justmigrating

    (@justmigrating)

    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

    justmigrating

    (@justmigrating)

    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.

    Plugin Author nickboss

    (@nickboss)

    Ok nice

    Regards

    Nickolas

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.