Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import WXR: Post authors not mapping #1446

Closed
justintadlock opened this issue May 21, 2024 · 0 comments · Fixed by #1477
Closed

Import WXR: Post authors not mapping #1446

justintadlock opened this issue May 21, 2024 · 0 comments · Fixed by #1477

Comments

@justintadlock
Copy link
Collaborator

When importing a post using an exported XML file from WordPress, it doesn't seem that the post authors are mapped to the Playground admin user. Therefore, when using the Post Author Name block to output the post author, it just appears empty.

You can use an example XML file from here: https://github.com/x3p0-dev/assets/tree/master/x3p0-ideas

bgrgicak pushed a commit that referenced this issue Jun 2, 2024
## What is this PR doing?

This attempts to set the correct user for WXR imports.

Reading the source for the WXR importer used, it appears
`default_author` should be set to the ID of the user (not the WP_User)
and will otherwise also be set to the current loaded user.


https://github.com/humanmade/WordPress-Importer/blob/140a53eb597de87d786cf942c8fe74fc97432f14/class-wxr-importer.php#L794-L807

## What problem is it solving?

Fixes #1446 Imports lack an author.

## How is the problem addressed?

Using the admin ID, and calling `wp_set_current_user()`.

## Testing Instructions

Note: This is an untested change.

Run the below playground, and verify if the imported post has an author
set.


https://playground.wordpress.net/?mode=seamless#{%22preferredVersions%22:{%22php%22:%228.0%22,%22wp%22:%22latest%22},%22phpExtensionBundles%22:[%22kitchen-sink%22],%22features%22:{%22networking%22:true},%22landingPage%22:%22wp-admin/edit.php%22,%22steps%22:[{%22step%22:%22importWxr%22,%22file%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/x3p0-dev/assets/master/x3p0-ideas/site-content.xml%22}},{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant