Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4535008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:21:06+00:00 2026-05-21T14:21:06+00:00

What I want to do using cURL: Login to my WordPress site, execute my

  • 0

What I want to do using cURL:

  1. Login to my WordPress site, execute my own PHP code and save it to a variable:

    $code_to_execute_remotely = wp_create_nonce(‘my_form’);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, ‘www.mywordpresssite.com’);
    curl_setopt($ch, CURLOPT_SOMEMYSTERIOUSFUNCTION, $code_to_execute_remotely);
    $resulting_variable = curl_exec($ch);

  2. Then use that variable in a 2nd cURL execution:

    curl_setopt($ch, CURLOPT_MYSECONDFUNCTION, $resulting_variable);
    $second_ececution = curl_exec($ch);
    curl_close($ch);

I’ve used dummy code to simplify things of course. The other functionality (logging into the remote site, etc.) is no problem, just executing that code remotely and returning its results as a usable variable, that’s all I need. Since I’m not terribly familiar w/ cURL, it’s possible I’m attempting something beyond its bounds, in which case I’d be very thankful to know what alternative could achieve this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:21:06+00:00Added an answer on May 21, 2026 at 2:21 pm

    On the remote site use the php eval function:

    http://php.net/manual/en/function.eval.php

    Edit with full explanation:

    On your local server:

    $post_data['curl_function'] = 'print wp_create_nonce("my_form");'; 
    $post_string = http_build_query($post_data); 
    curl_setopt($ch, CURLOPT_URL, 'www.mywordpresssite.com/receiver.php');
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch); //This will contain whatever receiver.php prints
    

    On the remote server in receiver.php:

    print eval($_POST['curl_function']);
    

    Notes:

    • This will only work if you can access the remote server http://www.mywordpresssite.com and upload the receiver.php
    • This is very unsafe for the remote server if you don’t sanitize the input and have a way to check so that only your local server can send this request.
    • But then again if you can access the remote server why send code through cURl when you can just write the functionality directly in receiver.php?
    • So the if you can’t access the remote server then the answer would be; No, you can’t run code through cURL on another server if you want access the remote server and upload files to it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to login users to other sites using PHP with cURL
I want to POST an URL using CURL and php. There is a big
I want to post XML data by using curl. I am using these code
Well, I want to login using cURL on some page. When i paste this
I want to get data using CURL but I have a problem. When I
I want to start using memcache with PHP (on Ubuntu 9.10). There are lots
Is it possible to login to my gmail account and send mail using curl
I am using curl to fetch website content into a variable. Now, using either
I heard about external access of a website using curl by the following code:
Alright I am practicing using cURL to login to different webservices. For this pariticular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.