Add Div to Comment Form

If you want to add some custom HTML between the </h3> and the <form> tags, you can try the following: /** * Add custom HTML between the `</h3>` and the `<form>` tags in the comment_form() output. */ add_action( ‘comment_form_before’, function(){ add_filter( ‘pre_option_comment_registration’, ‘wpse_156112’ ); }); function wpse_156112( $comment_registration ) { // Adjust this to your … Read more

Using ajax with wordpress

In WordPress Ajax works this way: First, you register the ajax action and the function you want to use to serve that action, of course, you have to write that function. All the request go to the same URL wp-admin/admin-ajax.php, what it changes is the action, and depending on the action, a different function is … Read more

How to know what submit button the user clicked?

The submit_button() function is a wrapper for get_submit_button(). Now that function has multiple arguments, but the most interesting for your actual problem is the 3rd argument name. It sets the HTML name attribute. <form action=””> <input … etc. <button type=”submit” name=”choice-a”> </form> Now everytime you process your form with an empty action attribute, you will … Read more

Add form fields dynamically on button click

You can do that using Javascript, by creating new DOM elements. You can use this Try it yourself functionality from W3Schools Copy and paste this code into Try it yourself and see how it works, it just adds a new paragraph: <!DOCTYPE html> <html> <body> <div id=”div1″> <p id=”p1″>This is a paragraph.</p> <p id=”p2″>This is … Read more

Ninja form Redirect depending on text field content [closed]

I am not sure whether you have hooked this function to appropriate action. Also you have not concatenated the strings properly: Instead of $newdestinationurl = $url/$destinationurlslug ; it should be $newdestinationurl = $url.”https://wordpress.stackexchange.com/”.$destinationurlslug ; Please see below for the complete code: function ninja_forms_handler() { add_action ( ‘ninja_forms_post_process’, ‘change_ninja_forms_landing_page’, 1, 2 ); } add_action(‘init’, ‘ninja_forms_handler’); function … Read more

Validate form in functions.php, send errors back to template

You need a filter not an action. Something like this (notes are commented into the code. You have a few PHP errors that you need to correct): function signup_validate_insert($post){ $errors = false; if (isset($post[‘submit_msg’])) { // validate , insert into database } return $errors; } add_filter(‘signup_insert’, ‘signup_validate_insert’); $errors = apply_filters(‘signup_insert’, $_POST); if((!empty($errors))){ // $errors is … Read more

How to implement post/redirect/get pattern on contact form

You could use the admin_post URL and actions to process form input and then redirect back to your page. The form: <form action=”<?php echo admin_url(‘admin-post.php’); ?>” method=”post”> <input type=”hidden” name=”action” value=”do_something”> <input type=”hidden” name=”origin” value=”<?php the_ID(); ?>”> <input type=”submit” value=”Submit”> </form> Then the action: add_action( ‘admin_post_do_something’, ‘wpd_do_something’ ); add_action( ‘admin_post_nopriv_do_something’, ‘wpd_do_something’ ); function wpd_do_something() { … Read more

Upload Image in a WordPress page using PHP

Implementing your own upload form like this can be a major security vulnerability, you might want to instead use a library/script where such potential issues are already dealt with properly. Here is one I remember using successfully on a project for a similar purpose (user uploaded video)… though it may be more than what you … Read more

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