Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: Set Cred Post Title to Author name, some text, Parent Post Title

$
0
0

Okay, so after working on this for another 6 hours I finally figured out a way to do it. It seems pretty simple now I've got it, but it's taken me until now to get my head around it. I guess that means I don't need support anymore, although I'd really like to leave this open for someone in support to have a look and let me know if there is a more efficient way of doing this. For anyone interested I have pasted in the code I cobbled together in the end..

1 – credformID is the ID number for the Cred form you are using.
3 – parent_id is the ID of the parent post this child post belongs to

==============================================================================================
1 add_action('cred_save_data_credformID','item_title');
2 function item_title($post_id) {

3 $parentID = get_post(get_post_meta($post_id, '_wpcf_belongs_parent_id', true));
4 $parent = $parentID->post_title;
5 $post_tmp = get_post($post_id);
6 $author_id = $post_tmp->post_author;
7 $author_name = get_the_author_meta( 'display_name', $author_id );

8 $post_title="$author_name some text $parent";
9 wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title));
10 }
==============================================================================================
Using this method gives you the post title for your post like – "'Author Name' 'your choice of text' 'Parent Post Name'"

So I could make my post title looked like "Jimmy Jim applied for the post of CEO"

Anyway, hope this helps someone else.


Viewing all articles
Browse latest Browse all 20145

Trending Articles