Pledge Meta: Update post title when org-name gets updated

The value in the `org-name` field is also used as the title of the
pledge post. If this value changes (via the Manage Pledge form, for
example), the post title should be updated as well.

There won't be any public way to change the post title directly, so
we shouldn't need to implement an auto-update of the post meta value.
This commit is contained in:
Corey McKrill 2019-10-18 16:42:50 -07:00
parent f95a4db541
commit 8d3c495d9b
No known key found for this signature in database
GPG key ID: C2C0746F7BF17E38

View file

@ -252,6 +252,14 @@ function update_generated_meta( $meta_id, $object_id, $meta_key, $_meta_value )
}
switch ( $meta_key ) {
case META_PREFIX . 'org-name':
if ( 'updated_postmeta' === current_action() ) {
wp_update_post( array(
'post_title' => $_meta_value,
) );
}
break;
case META_PREFIX . 'org-url':
$domain = get_normalized_domain_from_url( $_meta_value );
update_post_meta( $object_id, META_PREFIX . 'org-domain', $domain );