Skip Navigation

[Resolved] CRED hook custom code does not update post author

This thread is resolved. Here is a description of the problem and solution.

Problem: I have some custom code in a cred_save_data hook that is not updating the post author as expected.

Solution: Check to be sure post_author is defined correctly using the value of the custom field.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://codex.wordpress.org/Function_Reference/wp_update_post

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by JosV9233 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#629509

Hello Christian,

You helped me before with this. It was working, but I had to change a few things for the client and now a pretty crucial thing does not function anymore as it should.

I have an order form (name=Orderform id: 48) where I fill out orders. With the name of the client pulled from the users post type. Then I have a search and a view (name=Zoek op einddatum abonnement) where I search through and list the orders. In the search pulling the name works fine, in the list it doesn't do that anymore and here it shows the author of the post. I need to have the name on the order form being shown here also.

It is probably too cryptic for you to understand like this, so please allow me to send login credentials in a hidden post.

The url of the site is hidden link but the pages concerned are hidden. You need to be logged in as an admin to see them.

Best regards,
Jos

#629713

Hi, please share login credentials in the private fields here. I'll take a look and give you some feedback.

#629778

It used to come there but the client wanted to change things and so I messed it up and now it shows the name of the logged in person.
I can see it is set up to show the name of the author of the Telorder post:

<td>[wpv-post-author meta="user_firstname" format="meta"] [wpv-post-author meta="user_lastname" format="meta"]</td>

The problem is that the post author is not being set correctly any longer in the cred_save_data hook. In the functions.php file, you should add the post_author back to the post arguments array around line 93:

//collect data and define new title
    $my_post = array(
        'ID' => $post_id,
        'post_title' => $custom_title,
        'post_name' => $custom_title,
        'post_author' => $_POST['my_autor_select']
    );  

That should solve the problem.

#629855

Thanks a lot Christian, it solved the problem.
Great support again.
Have a nice Easter!

Jos