Create Resource Externally: Error in title


Well-known member
The following is inside of a function designed to write a resource from a WordPress post. An error is being returned "An exception occurred: Please enter a valid title -library/XenForo/DataWriter.php:1345" pointing to the set 'title' ...

Changing $title to '' returns the same error as well as 'New Resource'.

    $title          = $post->post_title;
    $content        = get_post_field('post_content', $post->ID);
    $date           = mysql2date('M j Y', $post->post_date);
    $author_id      = $post->post_author;
    $author         = get_the_author_meta( 'user_nicename', $author_id );

    $resourceWriter = XenResource_DataWriter_Resource::create('XenResource_DataWriter_Resource');

    $resourceWriter->set( 'user_id', $author_id );
    $resourceWriter->set( 'username', $author );
    $resourceWriter->set( 'resource_date', $date );
    $resourceWriter->set( 'title', $title );
    $resourceWriter->set( 'resource_category_id', $resource_cat_id );
    $resourceWriter->set( 'tag_line', '' );

Error message:

An exception occurred: Please enter a valid title. in /Applications/MAMP/htdocs/community/library/XenForo/DataWriter.php on line 1345

XenForo_DataWriter->_haveErrorsPreventSave() in /Applications/MAMP/htdocs/community/library/XenForo/DataWriter.php at line 1387
XenForo_DataWriter->save() in /Applications/MAMP/htdocs/wp-content/plugins/xenword- at line 48
xenword_insert_resource() in /Applications/MAMP/htdocs/wp-content/plugins/xenword- at line 19
call_user_func_array() in /Applications/MAMP/htdocs/wp-includes/plugin.php at line 496
do_action() in /Applications/MAMP/htdocs/wp-includes/post.php at line 3993
wp_transition_post_status() in /Applications/MAMP/htdocs/wp-includes/post.php at line 3456
wp_insert_post() in /Applications/MAMP/htdocs/wp-includes/post.php at line 3602
wp_update_post() in /Applications/MAMP/htdocs/wp-admin/includes/post.php at line 367
edit_post() in /Applications/MAMP/htdocs/wp-admin/post.php at line 229
Does anyone have any ideas as to why this code fails at the title?
Last edited:


Well-known member
Smart idea. Just tested and it returns the proper WordPress post title. The following string is based on a test post I just did with the title Resource var_dump.

string 'Resource var_dump' (length=17)