Integrate wordpress site with external system

Asked

Viewed 1,346 times

1

Good morning.

I am creating a wordpress site for the client, and I would like to know if it is possible to have such functionality and what should I do. I’ll explain how it should work:

The company works with importing products and equipment, the Sario who made an import enters the site, if logged in, being logged in he has access to a page where will see details about the import (such as: where the merchandise is, what date it left the country of origin, what date it should arrive, etc.), so each user will see the information of his merchandise, in addition to files (pdf, jpg, etc.) related to this.

Such goods information will be filled out in a system external to the site (by the company I’m serving), so I don’t have access to it. However such information will be sent (in txt) to the site, this should take such txt file and integrate the information in your database to be accessed by the user.

My doubt is how to do such integration with an external bank, and how each user will have access to only the data relating to their goods. So far I only know how to register subscribers, where all users have the same types of access.

Is that clear? I need to know if it is possible to do something like this, if there are plugins or tools to help with this.

  • Oops good morning, man it seems to me that you want to "consume" a service that comes there from your client and display it on a screen of the site, is that right ? I’ve never done in wordpress and not much manjo yet, but I imagine that that here can help you.

  • What you want is possible, but it’s so '70s it’s not worth it. Insist that your client fit into 2017 and refuse to receive this txt file.

1 answer

1

You can do this without plugins or external tools. Create a plugin and create a Post Type within it to save the information of each import.

To receive the information:

This depends on how and where TXT files will be accessible. Assuming it is a URL that your server can access, you can mount a WP Cron make a request to the URL and download the new files. Use wp_remote_get for that reason.

Once the files are on your server, just read the contents of each one using PHP (e. g file_get_contents) and create new posts within your Post Type by filling in Title, Content and other metadata you have, one for each import. This you do with wp_insert_post and update_post_meta.

To resolve access permission issues:

Create your users with a basic access level, e.g: Author. When saving the above post you search for the correct user in the database (use get_user_by) and places him as the author of the post. In your code you restrict which posts can be viewed by each user level, and make a global change in queries (using pre_get_posts) so that each user below a certain level (e. g, Editor) only has access to their own posts.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.