Sounds like you’ve got a fun challenge on your hands.
When you’re checking $_POST
directly in functions.php
, it might be too early in the WordPress lifecycle for the data to be available, or the action may be bypassing the logic you’re expecting.
Instead of using an empty action attribute in your form, it’s typically best to handle admin-side form submissions with WordPress’s admin_post
action hook.
Change your form’s action attribute to the following:
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
<input type="hidden" name="action" value="handle_update_streamline">
<input type="hidden" name="update-streamline">
<input type="submit" value="Update">
</form>
Then, in your functions.php, you’ll want to add:
add_action('admin_post_handle_update_streamline', 'my_streamline_update_handler');
function my_streamline_update_handler() {
if(isset($_POST['update-streamline'])){
create_properties();
}
// After processing, you might want to redirect somewhere like the settings page
wp_redirect(admin_url('options-general.php?page=functions'));
exit;
}
Give that a try! And don’t forget to adjust the code accordingly.