Importing excel files into Wordpress custom post - wordpress

I'm starting work on a new Jobs website (where client can create new jobs through the WP backend). This is easy enough with setting up with a custom plugin like post-meta
Wordpress - post meta plugin
Which I've setup with custom post meta fields (location, sector, status etc.)
However when I create jobs and fill out the post meta fields and check the DB they all have array encoding:
E.g. a:1:{i:1;a:1:{i:1;a:1:{i:0;s:11:"Sydney City";}}}
How do I remove this so it simply says 'Sydney City' for the meta key value?
But even if I fix that, the client needs to send me a spreadsheet with all the jobs, how do I import something like that into the DB? For example how can a spreadsheet like this:
Job Name,Advertiser,Status,Start,Finish,Category,Suburb,State
Value 1,Hays Constr,Tender,12/3/13,12/4/14,....
Be imported into the meta_key, meta_value architecture? Is it even possible?
What do you think would be the way to proceed? I do want the client to be able to edit Jobs in the WP Admin... but I also need to import a ton of jobs and surely there's a quicker way to do this

Related

Get all categories, custom field values in Wordpress query?

I've setup an API endpoint on a Wordpress site I'm working on, but the posts I'm retrieving have quite a bit of associated data, I think doing a query to get the posts then running the posts through a loop and getting this data will be too intensive, is there a catch all that can get all meta data at the same time as getting the posts?
If you're using REST API, you can use the function register_rest_field to add fields to responses. And then you can query all custom fields to put them in the responses.
If you're using a plugin like Meta Box to create custom fields, then you can use its free extension MB REST API to pull all the custom fields into REST API responses for you.

Serialized data in Wordpress form is "serialized" again when saved in mysql

I have a challenge with the way data is stored from Wordpress into mysql.
I'm new to Wordpress - but I'm trying to combine different plugins to achieve a specific functionality on a website.
Plugin #1 uses a specific type of post and some metadata - the plugin works great.
Plugin #2 can create posts of custom types and with custom metadata from the frontend. A flexible and great plugin.
My intention is to use plugin #2 to create posts from the frontend for plugin #1, which requires that some specific metadata contains specific values (otherwise the data are interpretted wrong). These values are saved with hidden inputfields in a form.
My challenge is that a value (which is serialized) is kind of serialized again. The value is a:1:{i:0;s:3:"198";}
Plugin #2 handles it well (as the data is shown correct in front- and backend of the plugin) - BUT in myPhpAdmin I can see that the data is saved differently s:20:"a:1:{i:0;s:3:"198";}"; - and hence that value cannot be understood by plugin #1.
I'm thinking of two options:
change something so s:xx: isn't added to the value(-s)
make the frontend form/plugin save the data in a serialized way so the value gets the correct format.
Any recommendations? - can I in anyway achieve my functionality?
Looks like
s:20:"a:1:{i:0;s:3:"198";}";
value is being serialized twice. You can check the plugin source code to see why the plugin serializing same value twice and if can prevent it than both plugin can share same data.

Drupal 7 - do something in a taxonomy hook after the database has been updated

I would like to do something after a taxonomy item has been inserted or updated. I tried using hook_taxonomy_term_update and hook_taxonomy_term_insert. However, anything you put here will execute before the database is updated. How can I do something after the database has been updated?
Specifically, what I'm doing is updating a text file that lists all the taxonomy terms. I pull this information from the database, so the db needs to be up to date before I write to the text file.
what you could use is
drupal_register_shutdown_function()
another option is to use module hook_post_action

Is update_user_meta secure in WordPress or is PDO approach needed?

I am currently using update_user_meta for users to update a custom bio field with info about themselves. I know update_usermeta was deprecated and that update_user_meta is the way to go now. However, I am just wondering if this is secure. It is not an sql query, so am I safe from any sort of sql injection, or do I need to figure out a way to update user bio info via PDO?
If I do need PDO, I'm not sure how to write that since the my $biotext variable saves as 'description' which falls under the meta_key column and does not have it's own column in WordPress.

Drupal Commerce order admin page, order id

I'm building a commerce site using Drupal Commerce. I've got it going very smoothly now but I've hit a dead end when I'm trying to create a module for handling shipping information and sending it to the shipping company for label printing.
The problem is, that I have created a new tab in an Order page,
admin/commerce/orders/order_id/printlabel
and I can access this page via a tab when I edit an order.
Now, I have no idea how I can pull the order_id number in the module. I have tried almost everything, entity_view, entity_metadata_wrapper, commerce_order.module API, but I have no idea how I can access the id and that is the key. When I get the ID, I can get the shipping information linked to it and I can send this data to the shipping company and save it.I also looked into the ways Commerce does things like combine Payment with Views but it seemed a bit too complicated for me to try so, I'm asking here. I can't get any answers on Drupal's own support forums.
Hope i got your question right.You created a custom menu admin/commerce/orders/*/printlabel where * is the order id of a particular order. You need the order id.
The simplest solution to it is getting it through the arguments or arg(). This is a function that drupal provides to get data from the arguments. For eg
if your url is www.xyz.com/admin/commerce/orders/0001/printlabel & you need order id i.e 0001 you can get it using arg(3).

Resources