I am trying to auto-change the post title of a WP User Frontend submitted post by adding some code into the functions.php file.
Below is the code that I've added into functions.php file, but no luck, it doesn't work.
add_action( 'wpuf_add_post_after_insert', 'update_title' );
function update_title($title) {
global $post;
if (isset($post->ID)) {
if (empty($_POST['post_title']) && 'post' == get_post_type($post->ID)){
$id = get_the_ID();
$title = 'Tuition Job - '.$id;} }
return $title;
}
For example, I expect the post title to change to "Tuition Job - 2343" when someone submits a post via the WP User Frontend plugin, but nothing happened.