Add Custom File Upload Field for Customers To Download On My Account Page in WooCommerce

The code in this download folder adds a file upload field to the user profile page for WooCommerce customers. The file download link is then added to a custom tab on the my account page for each customer as seen in the following screenshots :

File Upload

In addition to adding a custom tab named ‘File Download on the “My Account” page, the code also adds a custom file upload field on the user profile.

Adding a Custom File Upload Field :

  • The code introduces a new file upload field on the user profile page within the WordPress admin interface.
  • This field is labeled ‘File Download’ and allows administrators to associate a file with each user’s profile.

Conditions for Display :

  • The file upload field is designed to be accessible only to administrators. This is achieved by checking the user’s capabilities before rendering the field.
  • If the current user has administrative capabilities (specifically, ‘manage_options’), the custom file upload field will be displayed on the user profile page.

Functionality of the File Upload Field :

  • The file upload field allows administrators to manually associate a custom file with each user’s profile.
  • When administrators navigate to a user’s profile page in the admin area, they can upload a file using the provided field.

Customization for Administrative Use :

The inclusion of the file upload field is tailored for administrative purposes, providing a way for administrators to manage custom files associated with user profiles for any customer.

File Download

The code adds a custom tab named ‘File Download’ on the WooCommerce “My Account” page and modifies the entry title for a page associated with that tab.

Adding a Custom Tab :

  • The code introduces a new tab labeled ‘File Download’ to the user account navigation menu.
  • This new tab, when clicked, should direct the user to a custom page or endpoint within the “My Account” section.

Modifying the Title of the Custom Tab Page :

  • Once the user navigates to the ‘File Download’ tab, the code modifies the title displayed on that specific page.
  • The modification involves changing the default title to a custom title such as ‘Download File.’

Conditions for Modifications :

  • The modifications are not applied globally but are conditional.
  • The code checks specific conditions to determine whether the current page corresponds to the ‘File Download’ tab page.
  • If the conditions are met, it executes the modifications; otherwise, the default behavior continues.

Demo Video

Code Installation

There’s only 1 step :

Copy and paste the code to the end of your child themes functions file or custom/functionality plugin.

Download Folder

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.