0

I have a local installation of wordpress for testing and a production server.

I use XMLRPC to create custom posts with custom fields and everything works flawlessly on my local installation BUT it doesn't work for the production server. Custom Fields are not saved, I checked the table and it doesn't store it.

Is related to the underscores present in the start of the custom fields, for example: _al_listing_price

I have tried to store a custom field al_listing_price and it was saved in the database.

Where I can disable that behavior so it allow to post prefixed underscore custom fields?

2
  • Does WordPress version, theme and active plugins differ on local and production servers?
    – Max Yudin
    Mar 7, 2019 at 6:57
  • Yes, for the record I have fixed with register_meta function using this plugin gist.github.com/hugocf/4726663
    – fpilee
    Mar 7, 2019 at 15:00

1 Answer 1

1

You have to unprotect meta to be able to access it with XML-RPC:

<?php

function my_unprotect_meta( $protected, $meta_key, $meta_type ) {

    if( '_al_listing_price' == $meta_key ) {
        return false;
    }

}

add_filter( 'is_protected_meta', 'my_unprotect_meta', 10, 3 );

The solution you've mentioned in the comment to the question is 'duct tape' though it works. It completely removes meta value sanitization, which is the bad idea.

Your Answer

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

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