Problem setting pod title from fields on save
-
Hi,
I need to set the post_title of new pods according to the value entered in other fields. I’ve used the technique described in:
The title text is generated correctly, however the last step, actually setting the post_title, does not seem to have any effect. The Pod in question does support “Title” (advanced options).
Code:
private function add_filters() { add_filter('pods_api_pre_save_pod_item_membre', array($this, 'set_member_title'), 10, 2); } public function set_member_title( array $pod_array, bool $is_new_item) : array { if (!$is_new_item) { return $pod_array; } // get field values: ok $nom_perso = $this->get_custom_text_field_value($pod_array, 'nom_perso'); $prenom_perso = $this->get_custom_text_field_value($pod_array, 'prenom_perso'); $nom_org = $this->get_custom_text_field_value($pod_array, 'nom_org'); $titre = ''; if (!empty($nom_org)) { $titre = $nom_org; } else { $titre = $prenom_perso . ' ' . $nom_perso; } // debug: ok \aco\logging\log('titre: ' . $titre); if (!empty($titre)) { $pod_array['object_fields']['post_title']['value'] = $titre; } return $pod_array; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Problem setting pod title from fields on save’ is closed to new replies.