Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('cred_save_data', 'my_save_data_action',10,2);
- function my_save_data_action( $post_id, $form_data ) {
- // if a specific form
- if ( $form_data['id'] == 95 ) {
- $book_content = get_post( $post_id );
- $summary = get_post_meta( $post_id, 'wpcf-summary', true );
- $authors = get_the_terms( $post_id, 'book-authors' );
- //get authors
- $auth = array();
- foreach( $authors as $author ) {
- $auth[] = $author->name;
- }
- //insert the post
- wp_insert_post( array(
- 'post_title' => sprintf( 'New book is now available: %s', $book_content->post_title ),
- 'post_status' => 'publish',
- 'post_content' => sprintf( 'A new book has been added, %s by %s. <br /><br /><strong>Summary:</strong> %s', $book_content->post_title, join(', ', $auth ), $summary )
- ) );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement