-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add_message_action passes post ID of the workflow post rather than an ID of the triggering post #109
Comments
Example code: ->add_message_action(
'preview',
'Preview translated post',
function ( $post_id ) {
var_dump( $post_id ); // This prints the post ID of the hm_workflow post.
var_dump( get_post_type( $post_id ) ); // This prints hm_workflow.
var_dump( get_post_meta( $post_id ) ); // This prints meta data for the hm_workflow post.
return get_post_preview_link( $post_id ); // This would be the preview link of the Workflow post, not the post being worked with.
}, Example data:
|
The post ID you're receiving could possibly what's in the global scope at that time. It's strange though. The arguments are just what are passed via |
the action hook being used as a trigger is here: https://github.com/humanmade/playstation/blob/71f6b4cfdc1b9e2fed36694ff277fd28571a0070/content/mu-plugins/psn-l10n/inc/posts.php#L226 I can confirm after testing default workflow events, this may be related to the fact that the site where the workflow is saved is different than the site triggering the workflow but I can't find anything in the code that would explain why that would be the case. |
The documentation and sample code for
Event::add_message_action()
indicates that a$post_id
parameter is passed into the callable parameter. However, the post ID that's actually passed is the ID of thehm_workflow
post, not of the post itself. Therefore, the sample code provided:Would actually return the permalink of the workflow post, rather than the actual post to be viewed. Adding a callable
$args
parameter and$schema
does not appear to make any difference.The text was updated successfully, but these errors were encountered: