Under the USERS i have created 8 users. When one of those 8 users are loged in, they can write new post and publish it, and before they publish it they can select from the author dropdown list any nickname, but that doesn’t mean that user with that nickname wrote that post.
For example user X can select user Y from the dropdown list.
So in my case i have a lot of users who are selecting the same nickname from the dropdown list, because that nickname represents the global shared name of the company.
But then I don’t know who of those 8 users actually wrote that post.
So I want to display the name of the actual user who wrote the post, regardless of the author nickname selected during post creation.
I want to create new column in the post section and in that column I want to display that real user .
In that column I would like user to be displayed [by the NAME column in the “users” section…](https://i.ibb.co/3CCKXsh/Capture.jpg)
​
I asked Chat GPT to write me that code and he provided me this one that actually creates new column with the “Actual Author” label but unfortunately it doesn’t work as it should.
So maybe there’s just some little thing to correct or maybe the whole code isn’t correct. I don’t know cause I really don’t know how to code so maybe some of you could help me with this one.
I would be really greatful
I tried to tell GPT to redifine the code several times but none of them works :/
This is one of the codes it provides me:
​
​
​
// Add custom column
function custom\_posts\_columns($columns) {
$columns\[‘actual\_post\_author’\] = ‘Actual Author’;
return $columns;
}
add\_filter(‘manage\_posts\_columns’, ‘custom\_posts\_columns’);
​
// Populate custom column with actual author information
function custom\_posts\_custom\_column($column, $post\_id) {
if ($column === ‘actual\_post\_author’) {
$post = get\_post($post\_id);
$author\_id = $post->post\_author;
$author = get\_userdata($author\_id);
$actual\_author\_id = $author->ID; // Actual user’s ID
$actual\_author\_name = get\_user\_meta($actual\_author\_id, ‘first\_name’, true) . ‘ ‘ . get\_user\_meta($actual\_author\_id, ‘last\_name’, true); // Actual user’s name
echo $actual\_author\_name;
}
}
add\_action(‘manage\_posts\_custom\_column’, ‘custom\_posts\_custom\_column’, 10, 2);
​
​
[ad_2]
What I like to do is bounce the generated code between LLMs until it works. Single models usually have gaps.
Try bouncing the code to [Google’s Gemini bot](https://gemini.google.com); as well as Code Llama and other local models using LMStudio: https://lmstudio.com
In addition, there’s this great package: https://continue.dev/. Continue.dev will add AI coding assistants to VSCode for you.
All of these options are free.