0

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?

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? 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
    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? 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
    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
    Feb 21, 2019 at 16:57

1 Answer 1

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.

2
  • Dear Antti, thank you for your answer and time, but I need a solution, not the guide. I think that I have checked all the plugins I could find on the web, and couldn't find any plugin on the market, free or paid. I thought that Gravity form plugin can help, but it can't.
    – pendjer
    Feb 23, 2019 at 9:42
  • 5
    @pendjer, if you need a solution, then hire a developer. This is a Q&A website which offers help to a WordPress developers, and not a coding solutions for free.
    – djboris
    Feb 25, 2019 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.