Storing form data into wordpress database [closed]

This is a simple code to add a form in a page: add_shortcode( ‘myform’, ‘add_myform’ ); function add_myform( $atts ) { if ( isset( $_POST[‘myname’] ) ) { $myname = $_POST[‘myname’]; update_option( ‘myname’, $myname ); } else { $myname = get_option( ‘myname’ ); } $myform = “<form method=’post’ action=”>”; $myform .= “<input type=”text” name=”myname” value=”” … Read more

Woocommerce linking variations

I found a solution with a recursive function function decomposePrice($base, $iValue, $values, $prices) { $d = array(); foreach ($prices as $i => $p) { $baseP = “$base{$values[$iValue][$i]}|”; if (!is_array($p)) { $d[$baseP] = $p; } else { $d = array_merge($d, decomposePrice($baseP, $iValue + 1, $values, $p)); } } return $d; } $decomposePrice = decomposePrice(“”, 0, $v_values, … Read more

How to get value from wp_usermeta table in database?

You should be using add_user_meta instead of update_user_meta: if (isset($_POST[‘billing_cpf’])) { add_user_meta($customer_id, ‘billing_cpf’, $POST[‘billing_cpf’], true); } As this will only add the meta if it does not already exist – no update. (This will prevent this field from being updatable – unless by you another way.) Note: normally you could use something like this to … Read more

Refresh Customize Section (not preview)

It depends what “update” means. If you want just to hide or show the control, (like how WordPress sidebar area is appearing and disappearing when the sidebar is present or not) then you can use the active_callback parameter of the customize_control like this. Edit: Also, active_callback works on sections and panels too. If you want … Read more

Problem display

Enclose the while loop with a conditional: $the_query = new WP_Query( array( ‘p’ => $id_film) ); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ): $the_query->the_post(); // regular output endwhile; wp_reset_postdata(); } else { echo ‘No movie data’; }

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