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

creating form for wp_remote_post

You could make the form action be the current page’s URL. When the user submits the form the page gets reloaded with the POST parameters. Then in your widget’s code you check if those parameters exist. If so, you check them and then process them with your wp_remote_post. Personally I use Gravity Forms for stuff … Read more

Customize reset password form redirect problem

You can add the following to your functions.php to achieve what you are after. The action init doesn’t seem to fire in time for what you are looking for. if($_GET[‘action’]===’rp’ && strpos($_SERVER[‘REQUEST_URI’],’wp-login.php’)) { $key = isset( $_GET[‘key’] ) ? $_GET[‘key’] : ”; $login = isset( $_GET[‘login’] ) ? $_GET[‘login’] : ”; wp_redirect( site_url( ‘/reset-password/’ ) … Read more

Saving checkbox/option list status?

This is really just an html question, not specific to WordPress. Look into checked=”checked” (for check boxes) or selected=”selected” (for selects, radio buttons, etc.) In your case, <input type=”checkbox” name=”showS” value=”true” <?php if (get_option(‘showS’)==true) echo ‘checked=”checked” ‘; ?>> Since this is WordPress, though, I should also be reminding you to use the Settings API where … Read more

Return to option page after running PHP script

You said your original code is working. I think you should try using wp_redirect but you can’t output any HTML/Headers for that. Untested, but try the following: Note: intentionally missed out the html/body tags… <?php require_once(‘../../../wp-config.php’); require_once(‘../../../wp-load.php’); global $wpdb; $feedurl=$_POST[‘scimp_feed_url’]; $showcategory=$_POST[‘scimp_show_category’]; $table_name = $wpdb->prefix . ‘scimp’; $wpdb->insert( $table_name, array(‘feedurl’ => $feedurl, ‘category’ => $showcategory)); wp_redirect( … Read more

Reset recaptcha contact form 7 [closed]

Since the recaptcha is created by contact form 7 without assigning the rendered recaptcha to a variable it was not possible to use grecaptcha.reset(opt_widget_id). Here is what is did: $(“.wpcf7-submit”).click(function(event) { var currentForm=$(this).closest(“form”); $( document ).ajaxComplete(function(event,request, settings) { var responseObj=JSON.parse(request.responseText); if(responseObj.mailSent==true){ //reset recaptcha var recaptchaIFrame=currentForm.find(“iframe”).eq(0); var recaptchaIFrameSrc=recaptchaIFrame.attr(“src”); recaptchaIFrame.attr(“src”,recaptchaIFrameSrc); } }); }); I have cleared the … Read more

Form Processing

I’m not sure what the root cause of your issue is. But I do see a syntax error in your last code block, which could be what’s causing the white screen. Your “action” attribute is missing a close quote. Try this instead: <form action=”<?php echo esc_url( admin_url(‘admin-post.php’) ); ?>” id=”new_post” name=”new_post” class=”form-horizontal” method=”post” enctype=”multipart/form-data”>

How to Process Form Request

Rename your form fields so they don’t clash with WordPress query vars, specifically name. Reserved $_GET and $_POST terms in WordPress: attachment attachment_id author author_name calendar cat category category__and category__in category__not_in category_name comments_per_page comments_popup customize_messenger_channel customized cpage day debug error exact feed hour link_category m minute monthnum more name nav_menu nonce nopaging offset order orderby … Read more

404 on form submit [duplicate]

Do not use variable name “name” for html textbox control, use something else. This behavior is due to internal handling of WordPress with “name” variable found in query string of posted data.

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