WordPress.org

Forums

Frontend Uploader
Help? "Author" not being saved? (12 posts)

  1. websta
    Member
    Posted 2 years ago #

    It looks to me like Frontend Uploader is easily the best way to publish to WordPress from the public website; thank you!

    In anonymous and member posting, using Frontend Uploader, the author's name (which is included in the default form) is not being saved to my new posts, and I really need that.

    In frontend-uploader.php, I find the following code:

    // Save the author name if it was filled and post was created successfully
    			$author = isset( $_POST['post_author'] ) ? sanitize_text_field( $_POST['post_author'] ) : '';
    			if ( $author )
    				add_post_meta( $post_id, 'author_name', $author );

    Question: How can I call the author's name to either be attached to the post, or included in the email sent to the admin (willing to set that manually if I have to)???

    Is there something wrong with this code above? Any ideas at all?

    FWIW, the shortcode I'm using for my form is:

    [fu-upload-form category="#ofcategory" post_type="mycustomposttypename" form_layout="post_image"].

    http://wordpress.org/extend/plugins/frontend-uploader/

  2. websta
    Member
    Posted 2 years ago #

    To be clear:

    Frontend Uploader is saving the author's name in the database, but when you use a template tag...

    <?php the_author(); ?>

    ...it just displays "admin," not the author name entered in the Frontend Publisher default form.

  3. websta
    Member
    Posted 2 years ago #

    I see there is a new version of the plugin today. 8-)

    But it did not fix my problem. :-(

    I see the information about customizing forms. But, it does not fix the problem for me.

    1. It would be best if the author was automatically registered as a user, and the post was saved to author's name.

    2. Sending the author's name in the email to admin would be good, too.

    FWIW, similar plugins send admin email that look like this:

    Author : foo
    Author Email : foo@foo.com
    Title : The Author's Post Title
    Permalink : http://foo.com/the-authors-post-title
    Edit Link : http://sfoo.com/wp-admin/post.php?action=edit&post=1234

    In Frontend Uploader, my emails say:

    Someone uploaded a new UGC file, please moderate at: http://foo.com/wp-admin/edit.php?post_type=gallery&page=manage_frontend_gallerys_uploader

    So, author is not sent in email. But author is saved in database as author_name. So I am exporting database and searching for author_name to add to posts manually. It takes a lot of time.

    I think here is the email code:

    /**
    	 * Notify site administrator by email
    	 */
    	function _notify_admin( $result = array() ) {
    		// Notify site admins of new upload
    		if ( ! ( 'on' == $this->settings['notify_admin'] && $result['success'] ) )
    			return;
    		// @todo It'd be nice to add the list of upload files
    		$to = !empty( $this->settings['notification_email'] ) && filter_var( $this->settings['notification_email'], FILTER_VALIDATE_EMAIL ) ? $this->settings['notification_email'] : get_option( 'admin_email' );
    		$subj = __( 'New content was uploaded on your site', 'frontend-uploader' );
    		wp_mail( $to, $subj, $this->settings['admin_notification_text'] );
    
    	}

    Question: Is there a way to change email code to include the post title, permalink, and author_name?

    Also, how to add author's email in Frontend Uploader form?

  4. Rinat Khaziev
    Member
    Plugin Author

    Posted 2 years ago #

    Hey,

    Regarding the author - by default, all incoming files are attached to admin. The author field is supposed to be attachment meta field. Due to a bug it's not working correctly in current version. I'll fix it in 0.6.

    You can still save author as post meta using action hook.

  5. websta
    Member
    Posted 2 years ago #

    Thanks very much, Rinat. Awesome plugin. Good luck with version 0.6!

    Is there a way to include the author_name in the email to admins?

    /**
    	 * Notify site administrator by email
    	 */
    	function _notify_admin( $result = array() ) {
    		// Notify site admins of new upload
    		if ( ! ( 'on' == $this->settings['notify_admin'] && $result['success'] ) )
    			return;
    		// @todo It'd be nice to add the list of upload files
    		$to = !empty( $this->settings['notification_email'] ) && filter_var( $this->settings['notification_email'], FILTER_VALIDATE_EMAIL ) ? $this->settings['notification_email'] : get_option( 'admin_email' );
    		$subj = __( 'New content was uploaded on your site', 'frontend-uploader' );
    		wp_mail( $to, $subj, $this->settings['admin_notification_text'] );
    
    	}
  6. mulchkin
    Member
    Posted 2 years ago #

    On a related note, image meta data isn't being uploaded either :(

    Specifically, the title tag is not coming through. Is there a way to make the name of the image file save as the title for the image. This is expected and quite basic functionality for such a plugin.

    Many thanks!

  7. Rinat Khaziev
    Member
    Plugin Author

    Posted 2 years ago #

    mulchkin,

    They're being saved. If you go to Manage UGC and click edit on any single image, you'll see.

  8. Rinat Khaziev
    Member
    Plugin Author

    Posted 2 years ago #

    Hey guys,

    I just released v0.5.7, now the author is being assigned properly if it matches one of the registered users.

    Say you have user "bob"

    If this user will put "bob" into author field, post will be assigned to that user.

  9. websta
    Member
    Posted 2 years ago #

    Awesome! Thank you, Rinat! That will be a very big help to us and our users.

    Thank you again, Rinat!

  10. javitrance06
    Member
    Posted 1 year ago #

    Hi, i am having this same problem
    people upload their files but i cant see the name of the person who uploaded the file or the E-mail. I really need to fix this. so that i can be able to contact the person who uploads their files.
    Please help!!

  11. Stephen S
    Member
    Posted 1 year ago #

    I am having the same issue. The post is assigned to the admin (even in the back end) NOT to the logged in user who submitted the post. Any ideas? Thanks!

  12. Stephen S
    Member
    Posted 1 year ago #

    I'm sure there is another way to fix this, but I did it this way:

    $currentuserid= get_current_user_id();
    		// Construct post array;
    		$post_array = array(
    			'post_type' =>  isset( $_POST['post_type'] ) && in_array( $_POST['post_type'], $this->settings['enabled_post_types'] ) ? $_POST['post_type'] : 'post',
    			'post_title'    => isset( $_POST['caption'] ) ? sanitize_text_field( $_POST['caption'] )  : sanitize_text_field( $_POST['post_title'] ),
    			'post_content'  => wp_filter_post_kses( $_POST['post_content'] ),
    			'post_status'   => $this->_is_public() ? 'publish' : 'private',
    			'post_category' => $category,
    			'post_author' => $currentuserid,
    		);
    
    		$author = isset( $_POST['post_author'] ) ? sanitize_text_field( $_POST['post_author'] ) : '';
    		$users = get_users( array(
    				'search' => $author,
    				'fields' => 'ID'
    			) );
    
    		if ( isset( $users[0] ) ) {
    			//$post_array['post_author'] = (int) $users[0];
    		}

    (that is, got the current user id, added it to the post array, and commented out getting the first user, which I have no idea why it was there, but it works )

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Frontend Uploader
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic