• Resolved tazar64

    (@tazar64)


    Hello,

    I have created a relationship between Users (extended) and their CPT posts, let’s say “Diaries”.
    I want that when a user submits a form (using WPForms) with their post, to be automatically recognized in relationship with their posts. I have succeed this once but I cannot find the solution again 🙁

    So, I have created a field “xAuthor” in Diaries as follows:

    • Field Details: Relationship; Users
    • Relationship Options: Single Select, Autocomplete; Allow Add New = No
    • Advanced: Default value = {@user.id}

    In Users, I have created a field “related_posts” as follows:

    • Field Details: Relationship; Diaries
    • Relationship Options: Multiple select; Autocomplete; Allow Add New – Yes
    • Advanced: Default Value = {@id} // or nothing

    Everything works if I test the relationship from the Admin area (I choose an user for a Diary or I select one or more Diaries for a User).
    However, it does not work automatically when a user submits the form, the xAuthor is null and their Diary is without xAuthor. What settings should I do in PODS to get the current user automatically for the field xAuthor?
    I have succeeded once…! but unfortunately I lost my settings and I cannot redo it.

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

    (@keraweb)

    Hi @tazar64

    We have no integration with WPForms that I know of so I’m not sure how WPForms creates the posts and if it triggers Pods fields at all (probably not).
    You’ll have to look at their documentation and make sure you save the current user data as well (trigger saving the custom field).

    Cheers, Jory

    Thread Starter tazar64

    (@tazar64)

    That is not the problem – I use meta fields and everything works from this point of view.

    What it does not work is that the xAuthor field in the CPT is not populated automatically with the current user. (Default value = {@user.id} does not work, please see above). What settings should we use to get that?
    Thank you very much.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @tazar64

    That is my whole point. In order to populate the default values it will require the form to integrate with Pods since it will need to create the actual relationship.

    My guess is that this is not working because at the time of submit it it might be that at that point Pods isn’t fully hooked into the metadata handling.

    In any case, we do not have an existing integration with WPForms so I can’t be for sure how they handle submissions.

    Cheers, Jory

    Thread Starter tazar64

    (@tazar64)

    Thank you.

    I have solved that myself, it seems it is easy to integrate PODS with WPForms too!
    If there’ll be anyone else interested, it can be done by using their ‘hidden field’ and ‘custom post meta’ in submission. This way, you can send the user id to the CPT field that’s in relationship with User.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @tazar64

    Awesome, thanks for sharing!

    Cheers, Jory

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘User CPT settings for automatic Relationship’ is closed to new replies.