• Resolved xerviami

    (@xerviami)


    Dear,

    I am building a site where users will be able to register new CPT/POD.

    Therefore, I would like to create new PODS with PHP.

    Is there a way to do this ?

    I did not find a function to create a new POD.

    I tried the duplicate() function to duplicate an empty POD (and then add fields) but it seems to work only on POD items.

    I also tried to use WP-CLI to create a POD. It works but sometimes command lines are not ending (without any previsibility) and I have to kill these processess… which is not a behavior that is wanted… ??

    Thank you very much for your help !

    Xerviami

    • This topic was modified 1 year, 5 months ago by xerviami.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    This is the recommended way to register configurations for Pods via PHP: https://docs.pods.io/code/registering-configurations/

    Thread Starter xerviami

    (@xerviami)

    Dear Scott,

    Thank you very much for your answer.

    I also tried these ways to register pods (either with JSON files or with PHP).

    Nevertheles, each method makes these pods non-editable…. -> there is no way (AFAIK) to add/modify fields, either with PHP or from UI.

    Is there a way to make them appear/editable the same ways as PODS registered from the database ?

    In general, is there any way to register PODS with the same results as the ‘wp pods pod add…’ WP-CLI command ? (this command register a new pod in the database and gives the same results as registering it from the UI)

    Thank you in advance

    Best regards

    Xerviami

    • This reply was modified 1 year, 5 months ago by xerviami.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @xerviami

    Since such configurations are static I don’t understand why you want to be able to edit them. Can you explain your situation and requirements?

    Cheers, Jory

    Thread Starter xerviami

    (@xerviami)

    Hi @keraweb ,

    > Since such configurations are static…

    My need is to have non-static POD creation/modification (same flexibility as UI creation, but with code). Therefore configurations are not a convenient way to perform it.

    My use case is:

    • user A creates from the frontend the CPT/POD n°1 -> he becomes the owner of this pod and will be able to add fields, modify its label, … or delete it (other users may be owners of other PODS)
    • other users are able to add/create/delete Items based on CPT/POD n°1

    I do not want to let user A access to the admin page because he would have access to some pod configurations that I do not want to (such as API enabling, pod template, admin page configuration, …).

    Therefore I am re-coding a way for user A to input his new CPT/POD informations from the frontend (name, fields, …) and I wand to pass these informations to a method which programmaticaly creates or modifies the POD.

    At this stage, the only way I found is by using WP-CLI.

    Thank you in advance.

    Xerviami

    • This reply was modified 1 year, 5 months ago by xerviami.
    • This reply was modified 1 year, 5 months ago by xerviami.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @xerviami

    Static config files are indeed not meant for such situations.

    Since you require a very dynamic way of creating and modifying Pods you will need to create an abstraction layer for this to have support for Pods owners etc.
    Pods just created the Pod objects, which do not include owners or visibility options itself, you’re either the admin or you’re not.

    You do have such options with the content created with these Pods (like Posts and Terms).

    @sc0ttkclark do you have any recommendations on such a situation?

    Cheers, Jory

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Create a pod with PHP’ is closed to new replies.