Upon further reflection, I realized that the second challenge may not be important after all. Rather, by always applying the same Groups group upon the creation of this post (some sort of “pending review” group), we could effectively force ourselves to review the user-submitted entry, and that review would be an ideal time to assign the “actual” intended Groups group.
BTW, this automatically created post is actually a custom post specified in a “Gravity Forms Advanced Post Creation Add-On” post creation feed.
So, only the first challenge applies: The goal is now to have this automatically created post, have a Groups group assigned at post creation. And, again, it will always be the same Groups group.
Hi giladehven,
Yes you can add a restriction to a post programmatically using
https://github.com/itthinx/groups/blob/master/lib/access/class-groups-post-access.php#L524
taking as argument an array of the post id you wish to add an access restriction and the group id you choose to restrict the post to.
Apart from this and since we are talking about a custom post type, also make sure to enable restrictions for this post_type under Groups > Options.
Hope it helps.
Kind regards,
George
Plugin Author
Kento
(@proaktion)
As this is related to a premium plugin, I would suggest to check the docs https://docs.gravityforms.com/category/add-ons-gravity-forms/advanced-post-creation-add-on/ or get in touch with the developers to see if they provide a hook that you could use that is triggered when the post is created. At that point you could then assign it to the appropriate group.
Thanks, George!
I should be able to have a chance to work on this over the coming weekend. I’ll report back after I’m done.
Kento: to be clear, I have everything working on the GF side just perfectly. It’s only the Groups side of this effort that I am researching with this post. George’s answer seems likely to be what I’m looking for, so I’ll continue my efforts there. Of course, if you have any additional input on the Groups side of this challenge, I’d love to “hear” it. The more the better!
Plugin Author
Kento
(@proaktion)
@giladehven Sounds like you’re right on track with @gtsiokos’s suggestion – BTW if you need examples of working with Groups there’s https://docs.itthinx.com/document/groups/api/examples/ which might be helpful