I have the latest WordPress version and PHP 7.3
I would like to use the API that is available since 4.7 as long as I read.
For now, I have installed the ACF Pro and I have added some custom fields in Users
But my problem is that these custom fields does not appear in API
I would prefer not to use any plug-ins (if it is not nessasery in order to have a stable code, rather than updates and plug-ins covering other plug-ins.. and so on.. ), but of course if this is the only and easier way, let's go we that!
I have done so far "How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes"
through another post here in overflow: How to expose all the ACF fields to Wordpress REST API in both pages and custom postypes
which it was also helpful for other reasons.
I have already installed ACF to REST API - v3 plugin, but I do not know the next steps.. Custom fields still does not appear yet. what should I do after that?
Furthermore, I have tried and installed "JSON API User" but I think I am missing something..
Could you give me some explanations how all these works, and steps to continue? I would like to have my custom fields of Users available to API (fields I have like classes, sectiones, PIN and so on)
Related
I’m building a WP plugin to enhance a website, and come to an interrogation with the workflow.
Basically, I have to create a custom post type, assorted with several custom taxonomies, which will be used/displayed on the frontend and backend, and create a backend section in order to interact with our CRM, and Supabase via their respective APIs (service centralisation).
All of the second part is only intended to be used/displayed on the admin section, to logged users.
However, when creating/saving a custom post type, or when viewing it from the frontend, I have to make a GET request to the CRM to fetch some data and store it in JSON somewhere (24h cache).
That I can do.
At the moment, I worked on the CPT part, and made a class to interact with the CRM, with credentials stored in wp_options. I now have to work on the backend part.
My question is: what are the best practices here? Keep it in a single plugin or divide into several plugins?
And if I divide, how should I turn it? 2 plugins, one for the CPT and one for the backend? Or go even deeper, and get the CRM and Supabase their own simple plugin, and call their methods to make my requests?
I am short of ideas here, so if you encountered this situation, could you enlighten me?
I tried to use one plugin called "WP Data Sync". I am also going through its documentation/ support for the same. I am also having wpbakery page builder in my website. So is there any way that we sync with that also?
Note - We have to sync data in the form of images, image gallery, events listing, and the blog posts.
Did you check out WP Data Syncs website at https://wpdatasync.com/ and create an account to check out an API key?
I'm not sure about all APIs, but the ones I've used in the past would require me to register with the API's website, get issued an API key and maybe even designate the key to a specific website (your WordPress site in this case) for security reasons. After that, you would then go to your WP site and setup the API there via WP DataSyncs plugin.
I hope I understood your question and that this helps.
I'm creating a wordpress plugin that communicates with woocommerce installed on the same wordpress site. I noticed that the rest api requires ssl to use, but it seems like ssl locally is not possible and oauth is a pain in the ass.
Is there a way to develop for woocommerce locally without having ssl that doesn't use oauth?
I would recommend beginning by throwing out the idea of calling back to a local site over any HTTP/S protocol. That is almost never the right decision.
Instead, woocommerce has extended the WordPress hook/filter system into themselves: https://docs.woocommerce.com/document/introduction-to-hooks-actions-and-filters/. This allows you to inject/extend yourself throughout woocommerce without making a cludgy callback system. I don't know what you want/need to do, but I can guarantee the hooks should probably get you all the functionality you will need.
If you truly do need to make API calls back. You basically won't be able to develop locally (without a lot of effort setting up a local server environment). Instead set up a development environment on a separate server.
I assumed this is a mostly php plugin running on the server. If instead this will be serving a lot of javascript to the frontend, then you will have to use the REST API, and you will have to get some development server up with ssl.
Update: based on comment below expounding on purpose. I assume you figured out to add the 'sales goal' information as post meta to the woocommerce product. Here's a quick introduction to post meta if you need it: https://dsgnwrks.pro/how-to/what-is-post-meta-an-intro-to-wordpress-custom-fields/. This would be the best practice for adding information to the products.
For the proportion of sales to the goal. You will first need a function to get the total sales to date on this product. Here is a gist that hooks into woocommerce_single_product_summary and gets the post_meta total_sales on the current product. You should be able to use a similar scheme to get both total_sales and your sales_goal post meta and then just display the ratio in whatever way you choose.
Note: You may need to attach to a different hook. Or you may even need to get the current product a different way (maybe specified by the widget?) to get ahold of the post_meta.
I have a Laravel 4.2 app with REST API, And I want to save the orders in my app database by using api
How can I do this? Should I modify Woocommerce Plugin or do something else?
Possibility #1
You need to make your own wordpress plugin and communicate with your Laravel app API endpoints.
Woocommerce receive order -> Plugin -> Curl -> Laravel API
I think there is ample information out there on how to create your own Wordpress plugin to do that, also you might want to look into the WooCommerce Documentation for relevant functions.
https://premium.wpmudev.org/blog/wordpress-plugin-development-guide/
https://code.tutsplus.com/tutorials/laravel-4-a-start-at-a-restful-api-updated--net-29785
Possibility #2
You can have a script on the Laravel APP side which will query the WooCommerce API and pull the latest WooCommerce orders.
https://docs.woocommerce.com/document/woocommerce-rest-api/
https://gist.github.com/sisou/889971461616661d2ed6 (Laravel 4 Cron inspired from Laravel 5 scheduler)
https://github.com/Indatus/dispatcher
Important : Never modify a core WordPress functions and avoid modifying any plugins (unless done with proper documentation and professional intent). This will avoid you further problem down the line you don't want and don't need. Also it is 99% of the time unnecessary since you can filter plugin functions and execute different task along any WordPress plugin.
I have my own custom gallery CMS which is built using php & mysql. Now I want to make this as a wordpress plugin for my client, meaning my custom gallery admin panel will be shown in wordpress as a single plugin.
How can convert my script to be a wordpress plugin? I am new to wordpress so I really have no idea about making plugins, so I'm wondering if I can just add a few lines of code and just by making a few changes to my script I can make it all work as a plugin?
Before you go any further, you should really question integrating your own CMS into WordPress. I've done this before, and it ended up having a lot of disadvantages in the long-term, like not benefiting from functionality and security updates from the WordPress team. The newer versions of Wordpress provide a lot of useful functions to generate your own custom admin functionality within WordPress, including Custom Post Types, Custom Taxonomies, Custom Meta Boxes, etc.
As an experienced WordPress developer, if I had a client that demanded more than the built-in gallery functionality that WordPress already provides, I would go one of two routes, depending on the requested functionality:
1. Add functionality to the existing WordPress gallery via hooks and filters
This site is an excellent resource to see just how deeply you can modify WordPress with hooks and filters:
http://adambrown.info/p/wp_hooks
2. Create a custom post type, client uploads images to the post as normal
This method you would just create a new 'gallery' post type, and the client would upload images with all of the built-in WordPress interfaces. You can add any additional functionality you need with functions like 'add_meta_box'... here's all the relevant links, including taxonomies if you need categorization and a good sort-by-taxonomy tutorial:
http://codex.wordpress.org/Post_Types
http://codex.wordpress.org/Function_Reference/add_meta_box
http://codex.wordpress.org/Taxonomies
http://justintadlock.com/archives/2011/06/27/custom-columns-for-custom-post-types
If you're absolutely hellbent on using your existing CMS, you can always load your code into an iframe on a custom WordPress admin page, but I don't recommend it based on experience. Here's a link that will guide you in that direction:
http://codex.wordpress.org/Administration_Menus
Just as a post-script, you can do any or all of these things either via a WordPress plugin or a custom WordPress theme. I tend to prefer adding functionality to a theme if I don't plan on sharing it with the world and documenting it, or if the functionality is very client-specific and not reusable.