• I have a client that needs to display data on the front end in the form of charts/graphs.

    Requirements are that they upload a CSV file in the admin panel that contains data sets relative to users (i.e., each user will have different value outputs). This data needs to be displayed on the front end in the form of graphs/charts once user logs in.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I don’t know if the usual media upload functions will be much help since CSV is not a media type. It may be possible to alter accepted file extensions and MIME types, but simply using standard PHP to handle CSV uploads isn’t too difficult. If the upload form submits to /wp-admin/admin-post.php, you can add a particular action callback to handle the form submit.

    Only logged on users should be able to upload, thus the file’s path could be stored in user meta for future use. It’d be a good idea to validate the file in some manner to prevent malicious code injection. If the files aren’t too large, parsing as CSV could serve as validation, any extracted values longer than a certain size could be malicious code, as does text like ‘eval’ and ‘base64’.

    Displaying the charts can be handled with a custom page template. Set the page created based on the template as the site’s static home page. If the user is logged in and has an uploaded CSV file in user meta, generate the charts. If not, display something else, a CSV upload form perhaps.

Viewing 1 replies (of 1 total)
  • The topic ‘Displaying Charts and Graphs Relative to User on Front End’ is closed to new replies.