I am using Wordpress for my clients to log into the site, put data in a customized table and save it in a database table. Through the code “example” that I put in funtions.php theme I can return my email at the top of the screen. Code below.
$ current_user = wp_get_current_user ();
$ logado1 = $ current_user-> user_email;
echo $ logged1;
however through a new blank page I can put the HTML to make it work correctly, including with the css via plugin. But I can't include the php on the page is to retrieve the data from the $ logado1 variable contained in theme / funtions.php. Well, I need to retrieve the data from “$ logado1 email”, and forward it to a next php referenced in.
<form action=" http://localhost/newphp.php" method="post">.
do the treatment and save it in a new table in the “registration” database.
<div class = "divsearch">
<form action=" http://localhost/newphp.php" method="post">
<label class = "textout"> <b> Port 1 </b> </label>
<input type = "text" class = "box1">
<label class = "textout"> <b> Port 2 </b> </label>
<input type = "text" class = "box1">
</form>
<button type = "submit" class = "buttonacept1"> Save </button>
</div>
Does anyone have any solution for this problem ?.
I am using Wordpress for my clients to log into the site, put data in a customized table and save it in a database table. Through the code “example” that I put in funtions.php theme I can return my email at the top of the screen. Code below.
$ current_user = wp_get_current_user ();
$ logado1 = $ current_user-> user_email;
echo $ logged1;
however through a new blank page I can put the HTML to make it work correctly, including with the css via plugin. But I can't include the php on the page is to retrieve the data from the $ logado1 variable contained in theme / funtions.php. Well, I need to retrieve the data from “$ logado1 email”, and forward it to a next php referenced in.
<form action=" http://localhost/newphp.php" method="post">.
do the treatment and save it in a new table in the “registration” database.
<div class = "divsearch">
<form action=" http://localhost/newphp.php" method="post">
<label class = "textout"> <b> Port 1 </b> </label>
<input type = "text" class = "box1">
<label class = "textout"> <b> Port 2 </b> </label>
<input type = "text" class = "box1">
</form>
<button type = "submit" class = "buttonacept1"> Save </button>
</div>
Does anyone have any solution for this problem ?.
Share Improve this question asked Jun 26, 2020 at 18:45 gabrielgabriel 32 bronze badges2 Answers
Reset to default 0As said by sabbir you have to create a custom template to use php code, other way is to register a shortcode and the use that shortcode on new page. creating shortcode is much easier, you can paste the code below in functions.php and then use [new_form] shortcode on your page. You can modify the code as per your needs...
function form_shortcode()
{
if (is_user_logged_in()) {
$current_user = wp_get_current_user ();
$logado1 = $current_user->user_email;
ob_start();
?>
<div class = "divsearch">
<form action=" http://localhost/newphp.php" method="post">
<label class = "textout"> <b> Port 1 </b> </label>
<input type = "text" class = "box1">
<label class = "textout"> <b> Port 2 </b> </label>
<input type = "text" class = "box1">
<input type="hidden" name="user-email" id="user-email" value="<?php echo $logged1 ?>">;
</form>
<button type = "submit" class = "buttonacept1"> Save </button>
</div>
<?php
}
$content=ob_get_clean();
return $content;
}
add_shortcode('new_form', 'form_shortcode');
You can't add php within visual editor or text editor by default. WordPress doesn't allow that. If you need a custom html page as a page you can always use a page template. Read more about page template here.
For minor cases you can use a plugin to add php as shortcode. Insert Php Snippet is a good one. You can read how to use the plugin here.