custom post types - How To Import CPT With Only Few TEXT ACF Fields From Front End?

admin2025-06-02  3

I have registered CPT "Contacts" and I have created 3 text fields: name, phone and address. All those fields are set as text fields, and now I want to allow admins to import CPT with those fields from front end.

Is there any plugin or script which can help me to achieve this?

I have registered CPT "Contacts" and I have created 3 text fields: name, phone and address. All those fields are set as text fields, and now I want to allow admins to import CPT with those fields from front end.

Is there any plugin or script which can help me to achieve this?

Share Improve this question asked Feb 18, 2019 at 9:09 pendjerpendjer 1283 silver badges11 bronze badges 9
  • What do you mean by "allow admins to import CPT with those fields from front end" exactly? Import from what? From uploaded CSV/XML/JSON/other files? External URL? And why admins? – Krzysiek Dróżdż Commented Feb 20, 2019 at 21:34
  • when the user is admin and he is loged in. CSV would be the best solution. there is no need for external source, i need only to upload the file. admin because I want to hide that option from other visitors. – pendjer Commented Feb 20, 2019 at 22:03
  • And where should that upload be accessible? You’ve mentioned front end, but if it’s only for logged in admins, then... Isn’t wpadmin more appropriate? – Krzysiek Dróżdż Commented Feb 20, 2019 at 22:08
  • no its not. i want to build a tool for account managers, and later I want to build the mobile app with that website. I don't want them to go to wp-admin area. But you may be right. Other user roles are also fine, like editor. It can be placed on any page. i would like to add the link in the navigation, so that they can access it. after the import all posts should be published, if there is no error. – pendjer Commented Feb 20, 2019 at 22:17
  • So it sounds like what you actually want is to CREATE a CPT from a submitted ACF from on the frontend ..is that correct? Not import, but CREATE – sMyles Commented Feb 21, 2019 at 16:57
 |  Show 4 more comments

1 Answer 1

Reset to default 4 +25

I'm not quite sure if there are any plugins that work out of the box the way you describe. You might want to do some research on the many importing plugins published for WordPress to see, if any of them support front-end importing with some kind of capabilities management.

I think that the most probable situation is that you need to do some custom development either by yourself or hire a developer to do it for you.

Based on your question and the related comments I think the concept for the import feature could be something along these lines.

  1. Create a custom form with all the necessary input fields and a file input field. You could perhaps have a custom shortcode render the form on the front-end.
  2. Create a custom user role with custom capabilities for those who need to be able to access and use the import form. With custom role/capabilities it might be easier to ensure the users won't be able to anything inappropriate. Which might be the case if you hand out admin or editor roles to users.
  3. Handle the import form posting in any suitable way. You can use PHP to extract data from a csv file, if there's one posted with the form. There's a good thread on How to extract data from csv file in PHP on StackOverflow.
  4. While / after extracting data from the csv file use wp_insert_post to create a custom post for each line of the file and add_post_meta to the posts as needed.

This is just a concept and I'm sure there are quite many details that need to be figured out and filled in before it works. But, this is the best answer I can give you based on the information you've provided thus far. I hope this at least gives you some new ideas on how tackle the situation and helps you come up with a proper working solution to match your needs.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748861039a314329.html

最新回复(0)