$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>xml rpc - Cannot save underscore custom fields in one wordpress installation using xmlrpc and underscores|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin7PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far