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?

0

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, privacy policy and cookie policy

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