How to check if a user has already uploaded a file in Wordpress?

0

I'm using the WPForms , PRO version plugin and added a button of upload file on this form.

However, I need to do the following checking:

  • A user submits a file through my form. When that same user comes back, and does another upload, how do I check to see if he has previously uploaded? And how do I change the content of the page, given this condition?

Ps: I have already done a function that verifies whether the user is logged in or not, and the form only appears for logged in users

    
asked by anonymous 05.12.2018 / 17:22

1 answer

0
Well, I found the answer. Basically, for you to do the tracking, it is just to take advantage of the database. I created a script to check if the user is logged in (all this in functions.php):

function check_user ($params, $content = null){
//verifica se o usuario esta logado
if ( is_user_logged_in() ){
//coloque o que vc quer fazer...''
}

and within that block of code, I created a connection to the database, and also got the user ID, with the code (the connection is not here, but it's very simple to do):

$id = get_current_user_id();

Then I created a query string, to give a SELECT on the table that made sense to me and I was able to bring the results with the following command (after executing the query string with the connection in a result variable):

$row = $mysqli_fetch_array($result, MYSQLI_ASSOC);

After that, I checked (I was looking at the 'action' column of my database):

if($row['action'] == "upload"){
$data = utf8_encode("Você já fez um upload");
echo($data);
}
else{
$data = utf8_encode("Você ainda não fez nenhum upload");
echo($data);
}'

I hope I have helped:)

    
07.12.2018 / 12:27