Getting $_POST data with custom submit button
-
I have a custom post type called “car”. The idea of this custom post type is to have:
‘title of car’ and ‘description of car’.
I also need to have some images uploaded to a directory via a custom meta box i have created:
add_action('admin_init', 'myplugin_add_gallery_cars', 1); add_action ( 'init', 'uploadFeatures' );
‘myplugin_add_gallery_cars’ outputs the form into a new wordpress meta box absolutely fine.
‘uploadFeatures’ is a function that runs through the file fields that are created by ‘myplugin_add_gallery_cars’ when the submit button is pressed.
Here is my code so far:
https://pastebin.com/jEZiuxNsYou can see nearer the bottom witin the function ‘myplugin_add_gallery_cars’ I have a submit button.
<?php submit_button( 'Upload images', 'secondary', 'uploadImages', false) ?>
I want to have that submit button launch the uploadFeatures function which contains some simple crap:
if(isset($_POST['uploadImages'])){ echo "A"; }
Thing is, this if statement never returns true.
If I take the form out of the whole add_action() equation, everything works absolutely fine: https://jamestrusler.co.uk/files/helpme.jpg . The problem is that my ‘uploadFeatures’ function is not seeing the $_POST data… or that it does not realise the form has been created.
Some errors:
Notice: Undefined index: slider_image in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 151
wp_die() =
A
Notice: Undefined index: slider_image in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 155Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 184
Notice: Undefined variable: candvAdmin_cars_table_name in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 189
Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 191
Notice: Undefined variable: extension in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 192
Notice: Undefined variable: size in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 193
Notice: Undefined variable: newname in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 194
Notice: Undefined variable: currentPost in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 196
File Uploaded Successfully!Notice: Undefined index: main_image in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 155
Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 184
Notice: Undefined variable: candvAdmin_cars_table_name in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 189
Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 191
Notice: Undefined variable: extension in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 192
Notice: Undefined variable: size in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 193
Notice: Undefined variable: newname in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 194
Notice: Undefined variable: currentPost in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 196
File Uploaded Successfully!Notice: Undefined index: gallery in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 155
Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 184
Notice: Undefined variable: candvAdmin_cars_table_name in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 189
Notice: Undefined variable: filename in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 191
Notice: Undefined variable: extension in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 192
Notice: Undefined variable: size in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 193
Notice: Undefined variable: newname in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 194
Notice: Undefined variable: currentPost in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 196
File Uploaded Successfully!Warning: Missing argument 1 for wp_die(), called in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-content\plugins\banner\cars.php on line 209 and defined in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-includes\functions.php on line 2682
Notice: Undefined variable: message in D:\InstallationFiles\wamp\www\classicandvintage.co.uk\wp-includes\functions.php on line 2692
- The topic ‘Getting $_POST data with custom submit button’ is closed to new replies.