• <?php
    /*
    Plugin Name:My Plugin
    */
    
    function my_function($text){
    	if(isset($_POST["name"])) {
    		$name = $_POST['name'];
    	} else {
    		echo "
    			<form method='post' action='options.php'>
    			name : <inputtype='text' name='name'>
    			<input type='submit' value='submit'>
    			</form>
    		";
    	}
    
    	$text = str_replace('foo',$name,$text); //replace $name -> foo
    	return $text;
    }
    
    add_filter('the_content','my_function');
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • From a quick look I see:
    inputtype=’text’
    which needs a space like:
    input type=’text’

    Thread Starter m1234x5

    (@m1234x5)

    <?php
    /*
    Plugin Name:My Plugin
    */
    
    function my_function($text){
    	if(isset($_POST["name"])) {
    		$name = $_POST['name'];
    	} else {
    		echo "
    			<form method='post' action='options.php'>
    			name : <input type='text' name='name'>
    			<input type='submit' value='submit'>
    			</form>
    		";
    	}
    
    	$text = str_replace('foo',$name,$text); //replace $name -> foo
    	return $text;
    }
    
    add_filter('the_content','my_function');
    ?>

    ==========================================================
    path : /wp-content/plugins/myplugin/options.php

    1. <form method=’post’ action=’options.php’>

    result = Object not found!

    or

    2. <form method=’post’ action=’wp-content/plugins/myplugin/options.php’>

    result = Fatal error: Call to undefined function add_filter() in D:\xampp\htdocs\thwordpress\wp-content\plugins\myplugin\options.php on line 23
    ======================================================================

    Anonymous User

    (@anonymized-3085)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘What went wrong? my plugin’ is closed to new replies.