Home›Toolset Professional Support›[Resolved] Set post author dynamically as current loggedin user when you submit the toolset form and generate post title
[Resolved] Set post author dynamically as current loggedin user when you submit the toolset form and generate post title
This thread is resolved. Here is a description of the problem and solution.
Problem:
Set post author dynamically as current loggedin user when you submit the toolset form and generate post title
Solution:
You can use the Toolset Form's hook "cred_save_data" to set the post author and generate the post title dynamically after you submit the form.
The problem is the "editors" and the "admin" has to be hable to edit the Contractor Post Type. But in this moment when they do this, the post type change of author, and broke the link between the original author and the contractor post type. And that's not what we need.
Any possibility of mantain the original author link? For display some info of it in the single and the views?
Hello. Thank you for contacting the Toolset support.
Can you please explain when you say:
But in this moment when they do this, the post type change of author, and broke the link between the original author and the contractor post type. And that's not what we need.
Do you mean that when you change the post author for any specific single Contractor post - what issue you are having. Can you please explain with bit more details or a example so I can guide you in the right direction.
If and admin or a editor edit the contractor this custom type loss the original author and the admin or the editor is the author in this moment. We don't want this we need the original author remains as the only author. If not the link is between the original author and his/her contractor IS broken.
Can you please share problem URL where I can see the issue and steps to see the issue.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
1 . The user acces to this form in "registre" (Image 2021-11-23 12_07_31)
2. When the form is filled the user acces acces to this form with an auto login. (Image 2021-11-23 12_09_38)
3. Then we need to aprove and probably modify the content by an editor or and admin in the backend. When this happen the autor doesn't have to change, in this moment or in the futures if we need to edit the reedited content by the real user.
We need this for give the user the possibilty of edit his profile and maintain the comunication with his email.
As I understand now, when user interact with the following form shown with the following image:
=> hidden link
And when they do modifications to that form as a admin or editor user - you want that the author of the that profile should remain as the loggedin user who created the profile first - is that correct?
I tried to login to admin using the admin access details you shared but unfortunately its not working at this end. Can you please send me working admin access details.
I have set the next reply to private which means only you and I have access to it.
Before that the text is pendding and not published since a editors or an admins moderate the text and images (in the wordpress admin panel / backend)and publish if all is ok. Sending in this moment a email to the contractor author with a comunication.
The problem is in this moment the contractor author change to the moderator. And that not what we need.
Before that the author has to be able to reedit his contractor type and the cicle restars again with the moderator, the comunication, etc.
If the author change we can't create a update form for the author in the frontend and the email link is broken.
Ok - as I understand, the flow is:
- user registers and add his profile using the following form: hidden link
- Once profile is submitted - admin or editor user will review it in the backend and the publish it
- so, when admin or editor user publish the profile after reviewing it from backend, when they publish it it changes the post author to admin or editor user and thats the issue - thanks for all clarifications.
So, when I checked your theme's functions.php file I see you already added the "cred_save_data" hook. I've adjusted the hook code as given under and added the post_author argument: