• pythonidea

    (@pythonidea)


    Hi, I am creating a custom form plugin that in the method="POST" will go to specific .php file to do some function but it seems the WP Frameworl/Functions didn’t call or didn’t define.

    this is my code in my custom plugin myform.php

    function SRMS_form_func( ) {
    	//require_once ( plugins_url( 'srmsform_post.php', __FILE__ ));
    	$form_ret = "<form action='".plugins_url( 'srmsform_post.php', __FILE__ )."' method='post'>";
    	$form_ret .= "</br><label>First Name</br></label><input type='text' name='givenName' value=''></br>";
    	$form_ret .= "</br><label>Last Name</br></label><input type='text' name='surname' value=''></br>";
    	$form_ret .= "</br><input type='submit' value='Submit'>";
    	$form_ret .= "</form>";
    
    	return $form_ret;
    }
    add_shortcode( 'SRMS_form', 'SRMS_form_func' );

    in my srmsform_post.php is this.

    <?php
      $srmshost = get_option('srmshost');

    in this line I always get an error of
    Fatal error: Call to undefined function get_option()

    how can I define functions in WP in srmsform_post.php when myform.php calls the POST method?

  • The topic ‘undifined function name in custom plugin’ is closed to new replies.