xml rpc - Cannot save underscore custom fields in one wordpress installation using xmlrpc and underscores

admin2025-06-02  1

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?

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?

Share Improve this question asked Mar 7, 2019 at 2:23 fpileefpilee 1013 bronze badges 2
  • Does WordPress version, theme and active plugins differ on local and production servers? – Max Yudin Commented Mar 7, 2019 at 6:57
  • Yes, for the record I have fixed with register_meta function using this plugin gist.github/hugocf/4726663 – fpilee Commented Mar 7, 2019 at 15:00
Add a comment  | 

1 Answer 1

Reset to default 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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748833066a314101.html

最新回复(0)