wp_nonce_field is breaking form for reasons unknown

wp_nonce_field() will echo its output by default, so set the $echo parameter to false: add_shortcode(‘signup_form’, ‘get_signup_form’); function get_signup_form() { $wp_nonce_code = wp_nonce_field( -1, ‘_wpnonce’, true, false ); $signup_form_code = <<<EOT <form method=”post” class=”popup-register” action=”/my-account/”> <p style=”text-align:center;”> <input type=”email” class=”popup-input” style=”width: 65%;” name=”email” id=”reg_email” placeholder=”Enter your email address”> <input type=”submit” class=”popup-input-submit button” style=”margin: 0; border: 1px … Read more

How to execute html code inside php?

I wouldn’t recommend writing PHP code in the content this way, e.g. for security reasons. Most likely the shortcode is using eval() and you need a valid PHP code snippet in each such call. The PHP documentation has this warning: Caution The eval() language construct is very dangerous because it allows execution of arbitrary PHP … Read more

Editing a text file from plugin menu

First of all put these all code inside in init hook, and use plugin_dir_path() func to get plugin dir path. add_action(‘init’,function(){ $plugindir = plugin_dir_path( __FILE__ ); if(isset($_POST[‘addition’])){ $file_open = fopen($plugindir.”dates.txt”,”w+”); fwrite($file_open, $_POST[‘addition’]); fclose($file_open); } echo ‘<form action=”‘.$_SERVER[‘PHP_SELF’].'” method=”POST”> <textarea name=”addition” COLS=50 ROWS=20>’; $datalines = file ($plugindir.”dates.txt”); foreach ($datalines as $zz) { echo $zz; } echo … Read more

Ajax form submit not working, returns 0

The action: ‘ajax_contact’ part in: var data = $form.serialize(); console.log(data); $.ajax({ url: ajax_contact.ajaxurl, dataType: ‘json’, action: ‘ajax_contact’, data: ajax_contact.data, is most likely the cause here, that your ajax request is failing. Move the action part into the data set instead. Since you’re serializing the form data, you could try to add: <input type=”hidden” name=”action” value=”ajax_contact” … Read more

Use $_POST data in functions.php

Try adding you query variable to the public query variable list like this. function wp280272_query_vars($vars) { $vars[] = ‘currency’; return $vars; } add_filter( ‘query_vars’, ‘wp280272_query_vars’ ); you then can access it via get_query_var(‘currency’);

Submit Form data to another page via Ajax (WordPress Way)

Modify the following code I have added action in it. $(‘#btnDoCalculation’).click(function(e){ var formData = $(‘#interest_calculator’).serialize(); $.ajax({ type: ‘POST’, url: ‘<?php echo admin_url(‘admin-ajax.php’);?>’, data:formData, dataType: ‘json’, action:calculate_investor_interest encode:true, }).done(function(data){ if(data.success){ console.log(data); var results = data.calc_results; var newData = results.reduce(function(collection, element){ var rowData = {}; //create a new empty row element.reduce(function(collection, element){ //put the elements into the … Read more

textarea field is getting escaped for some unknown reason

WordPress always adds magic quotes regardless of server settings. This ensures consistency regardless of the environment. Even though magic quotes has been removed or deprecated from PHP, WordPress keeps this behaviour for backwards compatibility with older versions of PHP and plugins that were written with older versions of PHP in mind. If you want to … Read more

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