Home Forums Plugin Support WP User Frontend Pro Different form for posting and editing

This topic is: resolved

This topic contains 12 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 2 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #16794

    sociallyfamous
    Participant
    Post count: 91

    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.

    #16796

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #16850

    sociallyfamous
    Participant
    Post count: 91

    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

    #16906

    sociallyfamous
    Participant
    Post count: 91

    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?

    #16919

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #16922

    sociallyfamous
    Participant
    Post count: 91

    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.

    #16923

    sociallyfamous
    Participant
    Post count: 91

    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…

    #16924

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #16928

    sociallyfamous
    Participant
    Post count: 91

    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….

    #16929

    Tareq Hasan
    Keymaster
    Post count: 2831
    #16931

    sociallyfamous
    Participant
    Post count: 91

    Cool. Will try that. Thanks a lot.

    #16942

    sociallyfamous
    Participant
    Post count: 91

    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

    #16945

    Tareq Hasan
    Keymaster
    Post count: 2831

    Glad to know that.

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Different form for posting and editing’ is closed to new replies.