Integrate wordpress site with external system

0

Good morning.

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

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

Such merchandise information will be populated in a system external to the site (by the company I am serving), so I do not have access to that. However such information will be sent (in txt) to the site, it should take such a txt file and integrate the information in its database to be accessed by the user.

My doubt is how to do such integration with an external bank, and also 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 it clear? I need to know if it's possible to do something like this, whether there are any plugins or tools to help with this.

    
asked by anonymous 12.06.2017 / 17:14

1 answer

0

You can do this without external plugins or tools. Create a plugin and create a Post Type to store the information for each import.

To receive information:

This depends on how and where the TXT files will be accessible. Assuming it is a URL that your server can access, you can set up a WP Cron that requests the URL and downloads the new files. Use wp_remote_get for this.

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

To resolve access permission issues:

Create your users with a basic access level, eg: Author. When saving the above post you search for the correct user in the database (use get_user_by ) and put it 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 (eg, Editor) only has access to their own posts.

    
12.06.2017 / 19:36