Up to 50 percent off

Different form for posting and editing

This topic contains 12 reply and 2 voices, and was last updated by Tareq Hasan 10 years, 8 months ago
Viewing 12 Posts - 1 through 12 (of 12 total)
Author Posts
March 18, 2014 at 12:39 am 16794
Tareq Hasan Hello guys, I would like to use a different form for posting to a post type and for editing that specific post type. Could you suggest any elegant way of making this happen? Right now when I submit a post to a specific post type the appropriate form is automatically assigned to that post. Now when I want to edit that post, the same form obviously is used. However, I d like to use a different form that also contains image uploads for editing. I would be happy about any approach that you could recommend - one that does not force me to change it manually for each post and one that does not force me to regularly use a function to do the same. The only thing that comes to my mind is a cron job to update post meta regularly but that seems like too much of a hack. ------------ The back story to this is that my developer was not able to upload images to a custom directory when posting as he says that he is not able to get the post id to do so. (we wanted to have folder for the uploads/folder/post type/author But he managed to do it on post editing. So we had to do some sacrifices on the work flow and only allow image uploads after the post has been posted. If there is any hint on that issue that will be amazing from your part... as image uploads into custom directories seems to be one of the biggest problems with WordPress according to my research. Thanks in advance and sorry for the rather long question.
March 18, 2014 at 12:47 am 16796
Tareq Hasan Tareq Hasan

So if you could upload in different directly at the first place, would you still be changing the form?

March 18, 2014 at 4:23 pm 16850
sociallyfamous sociallyfamous

Of course this is a painful workaround and uploading into a custom directory would be the ideal scenario. There would be no need for a second form if this could be solved in the first step of submitting. Would you have any solution to this?

//I have tried replying to this via mobile but it is not showing just yet so excuse me if this turns out a double entry

March 19, 2014 at 5:11 pm 16906
sociallyfamous sociallyfamous

Tareq, I am about to lock myself in into the work around solution unless you have some news for me. What did you have in mind?

March 19, 2014 at 7:04 pm 16919
Tareq Hasan Tareq Hasan

Try this code:

[php]
function wpufe_change_upload_dir( $upload ) {

$subdir = ‘/my_uploads’;
$upload[‘path’] = $upload[‘basedir’] . $subdir;
$upload[‘url’] = $upload[‘baseurl’] . $subdir;

return $upload;
}

function wpufe_add_filter_change_upload_dir() {
add_filter( ‘upload_dir’, ‘wpufe_change_upload_dir’ );
}

add_action( ‘wp_ajax_wpuf_file_upload’, ‘wpufe_add_filter_change_upload_dir’, 9 );
add_action( ‘wp_ajax_nopriv_wpuf_file_upload’, ‘wpufe_add_filter_change_upload_dir’, 9);
[/php]

Paste this on your themes functions.php and it’ll change WPUF’s upload dir to /wp-content/uploads/my_uploads. Make the directory first.

March 19, 2014 at 7:22 pm 16922
sociallyfamous sociallyfamous

I am using a dynamic population based on custom post type. So each post type should have its own folder and each author has a folder within that post type folder. Uploading images into one folder only will create a huge mess on a large site, especially with the thumbnails.

I will pass on the code however, maybe there is something we can use from it.

March 19, 2014 at 8:10 pm 16923
sociallyfamous sociallyfamous

Thanks for the help. If there anything you can add to identify the post id to know how to assign author name or user id along with the post type it would be awesome…

March 19, 2014 at 8:25 pm 16924
Tareq Hasan Tareq Hasan

Currently it’s not possible to guess the post type as when you upload a photo for a post, the post is not created yet. So we don’t know what post type it is uploading for. In admin panel, it can be guessed, but not in frontend.

March 19, 2014 at 8:46 pm 16928
sociallyfamous sociallyfamous

So I guess I am back to the problem with the two editing forms or to hiding image fields on submission and showing the image fields on editing….

March 19, 2014 at 8:47 pm 16929
Tareq Hasan Tareq Hasan

Ha ha, okay.

Here’s the example: http://wedevs.com/support/topic/hide-fields-in-edit-form/#post-6886

March 19, 2014 at 9:01 pm 16931
sociallyfamous sociallyfamous

Cool. Will try that. Thanks a lot.

March 20, 2014 at 1:34 am 16942
sociallyfamous sociallyfamous

FYI – we were able to fix it by attaching the upload directory to the current user role as this is available in our particular case

March 20, 2014 at 2:10 am 16945
Tareq Hasan Tareq Hasan

Glad to know that.

Viewing 12 Posts - 1 through 12 (of 12 total)