custom field - Is there a simpler version of WP Media?

admin2025-04-18  1

I'm developing a plugin where users need to be able to upload an image (a payment receipt) to a custom user field. At the time, I'm using a code I found here Extra User Profile Field Upload File / Image and it is working. The problem is I don't want WP Media to show a lot of things, I just want the user to be able to upload a single image without seeing private site information or media and without being able to create something like a gallery.

Please, answer if you have any idea about how doing it. Thank you!

I'm developing a plugin where users need to be able to upload an image (a payment receipt) to a custom user field. At the time, I'm using a code I found here Extra User Profile Field Upload File / Image and it is working. The problem is I don't want WP Media to show a lot of things, I just want the user to be able to upload a single image without seeing private site information or media and without being able to create something like a gallery.

Please, answer if you have any idea about how doing it. Thank you!

Share Improve this question edited Dec 6, 2019 at 2:51 Julio Cesar de Azeredo asked Dec 6, 2019 at 2:24 Julio Cesar de AzeredoJulio Cesar de Azeredo 435 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use ACF to do this.

  1. Set up your custom field for the user profile.
  2. Use the acf_form() to produce a form containing the field on your front end for the user to interact with.
  3. Customise your acf_form() arguments to use a "simple" uploader (this will not expose WP Media Library to users then)

Example:

$field_arguments = array(
  'post_id' => 'user_'.$current_user->ID,
  'field_groups' => array(111), // Replace with ACF Group you created
  'form' => true,
  'uploader' => 'basic', // This is what hides the WP Media Library to the user
  'submit_value'    => 'Submit'
);
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744931989a275211.html

最新回复(0)