Create content of different entity by user programatically
The key is user_id, so presumably the correct code would be:

$post = Post::create([
  'type' =&gt; 'post',
  'field_post' =&gt; $post,
  'field_visibility' =&gt; 1,
  'user_id' =&gt; 2,
]);

$post-&gt;save();


I changed the var name to $post as it's not a node and you don't want to confuse those two things. I also removed the type as the social post entity type doesn't have such a field.