0

For a specific development, I had to add a upload form to change the profile photo inside the admin user page.

functions.php

function add_link_avatar( $description, $profileuser ){
    $description .= '<form action="#">';
    $description .= '<input type="file" name="fileupload" value="fileupload" id="fileupload" accept="image/gif, image/jpeg, image/png">';
    $description .= '<input type="submit" value="submit" class="button">';
    $description .= '</form>';
    echo $description;
}
add_filter( 'user_profile_picture_description' , 'add_link_avatar' , 1 , 2 );

How can I get the $_POST in functions.php ?

What value it needs for the action attribute ?

4
  • The action is used to determine where the form will be submitted. You can use $_FILES['fileupload'] in your functions.php to get the files. Also you should add enctype="multipart/form-data" to your form.
    – Johansson
    Apr 23, 2018 at 17:01
  • Thank you ! To get $_FILES, how can bind the form with a specific function inside functions.php ?
    – J.BizMai
    Apr 23, 2018 at 17:07
  • You're welcome. This will be saved when the user saves their profiles, so you can bind your function to the edit_user_profile_update action hook. Here is an example.
    – Johansson
    Apr 23, 2018 at 17:11
  • 1
    Possible duplicate of How To Add Custom Form Fields To The User Profile Page? Apr 24, 2018 at 9:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.