prefix . "user_files_link"; if (count($_POST) > 0) { if ($_POST['action'] == 'add') { $rows_affected = $wpdb->insert( $table_name, array( 'user_id' => $_POST['users'], 'attachment_id' => $_POST['files'] ) ); } if ($_POST['action'] == 'delete') { $rows_affected = $wpdb->query( "DELETE FROM ". $table_name. " WHERE user_id = ". $_POST['userID'] . " AND attachment_id = ". $_POST['fileID'] ); } } $media_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => -1, ) ); $fileList = array(); foreach ($media_query->posts as $post) { $fileList[] = array( $post->post_name, $post->ID ); } ?>
To assign a file to a user, select the file from the left dropdown below, select the user you want to assign it to from the right dropdown below, and click the Assign File to User button.
Below are the files that are already assigned to the users. If you would like to remove a file from a user, click the Delete button on the line of the user file link you would like to remove.
| Users | Files | Delete |
|---|---|---|
| %user | %file | '. PHP_EOL . ' |