• Resolved Thodoris

    (@peltho)


    Before some months I wrote this topic Get the old value from custom field on save before new value saved, I solve the problem but I look easier solution…

    Here is the scenario…

    I have two PODS, the POD1 and the POD2, both are relative pods, I add category to POD1 depending from value of custom field on POD2

    When I add/remove relationship from POD1 post everything works
    When I add/remove relationship from POD2 post need to take values from field of POD1 and set categories again.
    I think will be more easy if I update POD1 but need to call pods_api_post_save_pod_item_post for POD1.

    There is any way to update POD1 programmatically and call pods_api_post_save_pod_item_post?

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @peltho

    You can enhance the code you’ve shared here: https://www.ads-software.com/support/topic/set-post-tags-from-a-pod-custom-field-field-value/

    Steps:
    1. Within that code, check what Pod is being saved (you can use the first parameter for this)
    2. If it’s POD1 then store the values you need for POD2 in a static variable (or use a class property!)
    2.1 Fetch POD2 relationships from current POD1
    2.2 Loop through each relationship and trigger the save action for each POD2 relationship
    3. If it’s POD2 then get the values you’ve stored in your static variable and save these into POD2 the way you need.

    Cheers, Jory

    Thread Starter Thodoris

    (@peltho)

    Hello Jory ( @keraweb ),
    Thank you for your reply, I will try it even I don’t get 100% that you say but you give me a hind.
    So, I guess is not possible to call pods_api_post_save_pod_item_post filter for specific post programmatically? it called only when save the post.
    One more think
    I made some test and I found some weird behavior.
    I POD1 -> FIELD1 have relationship with POD2->FIELD1
    If you set relationship values in post from POD1 and remove the relation from post in POD2 the values for relation between fields in database table _podsrel and values from _postmeta for post from POD2 removed correctly but the values in _postmeta for post from POD1 remains.
    I want to investigate more at new installation when I have time and be sure it happens always. This is normal or looks like bug?
    Where I can report it if it’s a bug?
    Thanks

    • This reply was modified 3 years, 6 months ago by Thodoris.
    • This reply was modified 3 years, 6 months ago by Thodoris.
    • This reply was modified 3 years, 6 months ago by Thodoris.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @peltho

    So, I guess is not possible to call pods_api_post_save_pod_item_post filter for specific post programmatically? it called only when save the post.

    Correct, this is a filter that is only called when saving a pod.

    If you set relationship values in post from POD1 and remove the relation from post in POD2 the values for relation between fields in database table _podsrel and values from _postmeta for post from POD2 removed correctly but the values in _postmeta for post from POD1 remains.

    This is probably related to a known bug: https://github.com/pods-framework/pods/issues/5190
    If you have any info to add, please let me know or add it on GitHub!

    Cheers, Jory

    Thread Starter Thodoris

    (@peltho)

    Thank you @keraweb

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Update pod programmatically and call pods_api_post_save_pod_item_post’ is closed to new replies.