Does WordPress Super User or Administrators can create and edit post and media on behalf of a user

Somebody can explain me how works wp.media object and how it defined the user and author that owns media? Does it use the session cookie and/or the user Logged in cookie?

This is not something that can be done with the wp.media call, not attributes will allow this or can be used to set this. This approach is a dead end.

Instead of trying to brute force the media library code into doing what you want, instead it would be much easier to do this:

When the media library has picked an image, ensure it has an author ID of X

Now the problem becomes a simple 2 step part which is much easier:

  1. How do I retrieve the ID of the selected attachment form the media frame?
  2. Given an attachment ID and a user ID, how do I set the user as the attachments author?

The first one is demonstrated in almost every tutorial of how to use wp.media to create an uploader and is the most common use case and best documented part of the code, and one you likely already have implemented.

The second has many options, ranging from creating your own AJAX handlers, using the REST API media endpoint to update the post author, to using wp.media itself!

In theory something like this might work:

attachment = wp.media.attachment( imageId );
attachment.fetch();
if ( desiredUserID != attachment.attributes.author ) {
    attachment.attributes.author = desiredUserID;
    attachment.save();
}

Note that if the user is able to pick images that have already been uploaded this means they can take over other peoples posts. This also will require the user to be able to make an authenticated request and can edit other users attachments, which won’t be an issue for an admin but might be elsewhere if you expand on this.

The important thing, is that you don’t have to mess with the internals of wp.media to do it all in one step. It would be nice if you could, but that doesn’t mean it’s the only method available to you.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino