using wp function in plugin and getting 500 server error
-
Hello!
I am writing a plugin that creates categories based on an amount specified by a form. So I have the form page, it works, you can access it from the dashboard menu. When the form is posted it sends to a php page with this code on it:
//includes this file so that I can use wordpress functions include '../../../wp-includes/pluggable.php'; //comes from the amount specified by the form $assignmentamout = $_POST['assignmentamout']; //comes from what to call the categories input part of the form $namethem = $_POST['namethem']; //if the input box for naming the assignments is blank, this is the default if($namethem == "") $namethem = 'Assignment'; //repeat the createcat categories function for as many times as stated in the form for ($i = 1; $i <= $assignmentamout; $i++) { $create = $namethem." ".$i; createcat($create); } //run this function as many time as the loop says function createcat($created){ wp_insert_term($created, 'category'); }
If I click ‘submit’ on the form. I immediately get a server error: “HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.”
I tried putting the wp_insert_terms() directly into the loop and tried using wp_create_category(). If I do not include the pluggable.php I get a ‘function not found’ php error. I ran a lot of echos so I know that the script just stops at the wp_insert_terms(). I tried to look up server errors, but my server didn’t log any errors. I increased my memory in my php5.ini to 20mb. All my files in my plugin and its folder are permission 755. Plugin’s that I have installed from elsewhere are working properly. If I remove the wp function I get no server error, the page outputs echos I put at the end.Maybe I am just building this plugin incorrectly. Any help that anyone could give me would be much appreciated! Or maybe suggest how you would build this part of a plugin.
- The topic ‘using wp function in plugin and getting 500 server error’ is closed to new replies.