简体   繁体   中英

How do I pass values between two wordpress websites?

When a user visits a wordpress website, he/she should be redirected to another wordpress website with post title as form data passed on.

I did this using a php, I need to know how I can do the same using wordpress. This is the code I have used.

<?php
session_start();
$title=get_the_title();
$pass_value='https://example.com/reader.php?title='.$title;
?>
<form method='post' action='<?php echo $pass_value?>'>
<div align="center"><input type='submit' name='postread' value='read' /></div>
</form>

I have embedded the above code in a php code widget. The passvalue am catching using a php file that gets the title and processes the title. How do I make a wordpress page do the same.?

How about a curl request and a redirect header?

<?php
session_start();
$title=get_the_title();
$pass_value='https://example.com/reader.php?title='.$title;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"https://example.com/");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "title=$title");   
$server_output = curl_exec($ch);

curl_close ($ch);

header("location: $pass_value")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM