T
T
thehighhomie2016-01-30 10:50:00
WordPress
thehighhomie, 2016-01-30 10:50:00

Loading images in the created wordpress plugin?

When creating a plugin in wordpress, where you need to implement the loading of avatars for users, or for some other needs, not through the admin panel but directly on the site page, are there any functions or methods already ready for such things in wordpress, or can you easily create an upload folder in the plugin and upload it there using the standard php method via move_uploaded_file()?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WP Panda, 2016-01-30
@wppanda5

media_handle_sideload()
media_handle_upload()
if you need to change the upload directory, do something like this

function cr_set_upload_dir( $upload ) {
    $upload['subdir'] = '/video';
    $upload['path'] = $upload['basedir'] . $upload['subdir'];
    $upload['url']  = $upload['baseurl'] . $upload['subdir'];
    return $upload;
}

in the download handler
add_filter( 'upload_dir', 'cr_set_upload_dir' );
// загрузка файла
remove_filter( 'upload_dir', 'cr_set_upload_dir' );

I
Ivan Kozlov, 2016-02-01
@trampick

There is an AccessPress Anonymous Post plugin
https://ru.wordpress.org/plugins/accesspress-anony...
With it, you can create a form on a page from certain fields (name, text, etc.). It has a file upload feature. The plugin can be used for reviews. He adjusts well. You can disable/enable some fields. Specify text for messages, etc. All completed data falls into the system as a draft.
There is also a contact-form-7 plugin
https://ru.wordpress.org/plugins/contact-form-7/
With it, you can create various types of forms. You can attach files. All completed data is sent to the mailbox if necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question