Support » Developing with WordPress » Custom post meta not saved for author

Viewing 5 replies - 1 through 5 (of 5 total)
  • Guido

    (@guido07111975)

    Just found out it’s only happening in the new editor.
    No problem with saving custom post meta by author in the classic editor.

    A server error when using the new editor, info from console:

    
    (Fetch)POST - http://www.mydomain/wp-admin/post.php?post=234&action=edit&meta-box-loader=1&_wpnonce=3a3a92a4d5&_locale=user
    

    So it’s another problem with the new editor (Gutenberg) I guess..

    Guido

    Moderator bcworkz

    (@bcworkz)

    Hi Guido,

    Yes, seems to be a block editor issue. It’s odd that it only occurs to authors even though they have the proper capability. I dug into this a little bit and it seems the $_POST data is getting unset somewhere along the way. It’s valid in post.php, but by the time it gets to your “save_post” callback function, there’s nothing there. Your callback thus fails at the first check — check if the nonce is set. Since it has been cleared, your function returns, unable to do anything.

    I don’t see anything wrong with your code, it’s hard to do anything if the data is cleared. I’m not sure where or why the data is cleared, it’s apparently a block editor bug of some sort. One way to get you plugin functioning would be to track down the bug and patch the code. I don’t understand how the block editor works enough to debug it.

    The other approach is to work around the bug somehow. My inclination would be to install a JS event handler that updates the information via Ajax or API when the publish/update button is clicked. Or if you want to be more Google-like, update each field any time it changes 😉

    Guido

    (@guido07111975)

    Hi BC,

    Maybe the best thing to do is to report this at the Make WordPress Core page?

    I did find threads about similar issues but in those cases the custom post meta did not save for all user roles. In this case it’s only author (and maybe lower user roles).

    Guido

    Moderator bcworkz

    (@bcworkz)

    Yes, there ought to be a Trac ticket created to manage the issue. A step by step in the ticket to replicate the issue on a fresh WP install would very helpful. Some tickets are resolved quickly, others languish indefinitely. Being able to replicate the issue influences the chances of resolution.

    I installed your plugin to test, but that’s a lot to ask of Trac reviewers and can introduce unknown conflicts. Better would be a brief code snippet one could paste into functions.php that demonstrates the issue.

    Guido

    (@guido07111975)

    Hi BC,

    Thanks, I’ve created a ticket.

    Guido

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom post meta not saved for author’ is closed to new replies.