Modify Term Update Redirection

I agree with you, it’s somewhat an unexpected user experience, when you’re redirected after updating a term. Additionally there seems to be no error handling on the form itself, if you try to make some errors, like deleting the term name and slug, it will not show any errors, just ignore your changes and redirect. … Read more

inside a metabox

It’s not the right approach, since you are in a post(cpt) edit page the metabox’s are simple grouped fields that get attached to the post form and in your case it’s actually the browser who is filtering your metabox’s form attributes and not WordPress since you are creating nested forms which is something that you … Read more

Simple form that saves to database

For what I can understand you already have the table in your database. I don’t know how you have named it, but a best practise (for me a must-do practise) is to name it with the same table prefix of wordpress, that’s the one setted in wp-config.php. You also don’t say how this table is … Read more

Inserting data into custom tables

You said your form is in the main folder? I guess you need to set proper URL for action=””. You could try: action=”<?php echo site_url() . ‘/setLiquorType.php’; ?>” It is best practice to put your form code into functions.php and then leave form action=”” empty. Then you can trigger your form function when the form … Read more

Connect forms in WP to external database

You can easily connect to another DB using the wpdb class: $external_users_db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); (substituting in your applicable values, of course). From there you can use the get_results, insert, update, and query methods (among others) to do what you need to do, e.g. $external_users_db->get_results( “SELECT ID, username FROM users” );. The … Read more

Custom Form with Ajax

Your attempt to send your AJAX requests to wp-admin/admin-ajax.php is correct but it will be better to create a javascript global variable using wp_localize_script() to make any data available to your script in functions.php that you can normally only get from the server side of WordPress. For example, your javascript code can be in the … Read more

Refresh page after form action

Searching around and not being able to implement the action through init hook I’ve found this workaround which for sure isn’t the best but does the job nicely. echo “<script type=”text/javascript”> window.location=document.location.href; </script>”; at the end of $_POST instructions. If somebody has a better solution, welcome to share.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)