Hi
I have CPT called Actionitem. It has three parents (Actionplan, Process and Clientprocess).
Parent Actionplan is mandatory, while Process and Clientprocess is an either/or. Either Actionitem has parent Process or parent Clientprocess.
I create the Actionitems in my plugin, I assign an Actionplan (_wpcf_belongs_actionplan_id) and either a Process (_wpcf_belongs_process_id) or Clientprocess (wpcf_belongs_clientprocess_id), and everything looks fine and works as designed.
However, when I edit an Actionitem for eg. child of a Process in a CRED form and save it (only updating Actionitem fields and not relationships), the wpcf_belongs_clientprocess_id is created on the Actionitem with a value of 0 (zero). And opposite if editing an Actionitem for child of Clientprocess.
Is that intentional and per design? I havent seen this behavior before as Toolset normally doesnt store 'empty' values.
I see what you mean, if you edit a post with CRED the parent references are set to 0 but if you edit the post in wp-admin the behavior is different. I can reach out to the team to find out if this is on purpose or not, but to be honest relationship references are changing very soon in the M2M release, and I doubt changing the current behavior will be a top priority. Is this 0 causing a problem for you somehow? It might be more practical to work around that problem than to wait for a modification here.
Hi Christian
Thanks for you quick and clear response - once again 🙂
I fully understand and support the prioritization of the M2M release, and I will make the necessary changes to work around the 'uneven' behavior.
You bring up another important point for us as developers. Is there any documentation that we can read to understand the changes coming, and how it may impact our own coding and use of Toolset API?
Best
Ken
... and ...
In Toolset View, until today, I used this conditional check:
[wpv-conditional if="((!empty($(_wpcf_belongs_clientprocess_id))))"][wpv-post-title id="$clientprocess"][/wpv-conditional]
That is have now changed to:
[wpv-conditional if="( $(_wpcf_belongs_clientprocess_id) gt '0' )"][wpv-post-title id="$clientprocess"][/wpv-conditional]
So far I have been using (in PHP):
$clientprocess_id = get_post_meta( $quest_id, '_wpcf_belongs_clientprocess_id', true);
if (isset($clientprocess_id)) ...
Can you guide me as to how I safely should check for the presence of the parent in both Views and PHP?
You can change the conditional in PHP like so:
$clientprocess_id = get_post_meta( $quest_id, '_wpcf_belongs_clientprocess_id', true);
if (isset($clientprocess_id) && $clientprocess_id > 0) ...