Submitting Wordpress UserID,...

User 2396634 Photo


Registered User
12 posts

My website is a member based site and I would love to be able to have the form recognize the user ID and user login of the signed in user to submit with the form to the mySQL database.

I have gone ahead and added:

<?php global $current_user;
get_currentuserinfo();

echo 'Username: ' . $current_user->user_login . "\n";
echo 'User ID: ' . $current_user->ID . "\n";
?>

To the header.php file of my wordpress theme. The echo is just to make sure that it is grabbing the user info while I am testing this. The echo is printing the user info just fine.

On my Web Form Builder html file I added some hidden inputs with the code:

<input type="hidden" name="User_ID" value="<?php echo $current_user->ID; ?>"
/>
<input type="hidden" name="User_Login" value="<?php echo $current_user->user_login; ?>" />

Right now when the form submits it adds data into the "User_ID" and "User_Login" field, but unfortunately it is only printing exactly the "<?php echo $current_user->user_login; ?>" and "<?php echo $current_user->ID; ?>"

Do you have any ideas how to do this correctly?

FYI: A user will always have to be logged in to access this form and the form is being accessed through the iFrame code provided by Web Form Builder.

Thanks,
Brad
User 187934 Photo


Senior Advisor
20,193 posts
Online Now

This would be a great suggestion. I think I saw some others suggest that the form builder be able to display a variable.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 18194 Photo


Ambassador
289 posts

Would be nicer being more generic and able to setup for multiple types of CMS/Forums/Blogs... --Mitch
--Mitch
Long time CoffeeCup user, lover and ambasador !!
Mitchell Baker AMA 7548 GSWA WB251 10th AF USSMA 358
Webmaster Terre Haute R/C Club http://www.thrcc.org
US Scale Masters Director of Administration www.scalemasters.org
Proud member of the 1/8th Air Force http://www.oneeighthairforce.org


Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.