• Resolved fliebel

    (@fliebel)


    hi

    i am writing a plugin for wordpress witch stores data in option fields.
    so i have a nice form that submits to options.php, works fine, no problem at all.

    but i need to check and change some data first, before it is saved.
    for example, i have a email field split in to parts, one before the ‘@’ and one after it, and i need php to make it one field and save it.
    or make a JSON string of something… or maybe make some thing all lowercase…

    so my question is, how do i save option fields without js and forms, pure php.
    can i access them like set_option_field() or something?
    i tried this with curl:

    <?php
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
    
    if($_SERVER['REQUEST_METHOD'] === "POST") {
    	$url = "https://localhost:8888/michael/wordpress/wp-admin/options.php";
    	//$url = "https://localhost:8888/michael/wordpress/wp-content/plugins/programmering/test.php";
    	$ch = curl_init();
    
    	// set the target url
    	curl_setopt($ch, CURLOPT_URL,$url);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    	// howmany parameter to post
    	curl_setopt($ch, CURLOPT_POST, count($_POST));
    
    	$fields = "";
    	foreach($_POST as $key => $value) {
    		$fields .= $key ."=". $value ."&";
    	}
    	//echo $fields;
    	//echo "hoi";
    
    	curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    
    	$result = curl_exec($ch);
    	curl_close($ch);
    	echo $result;
    } else die("hacking atempt!");
    ?>

    but it does not work…

  • The topic ‘redirect form request for options.php – edit data first’ is closed to new replies.