【发布时间】:2021-05-24 21:20:47
【问题描述】:
我想使用 wordpress 中的 elementor 表单更新 phpmyadmin 上的表格,
但我无法取得任何进展,因为记录仍未更新
这个函数应该包含在functions.php文件中。
add_action( 'elementor_pro/forms/new_record', function( $record, $ajax_handler ) {
//make sure its our form
$form_name = $record->get_form_settings( 'login_form' );
// Replace MY_FORM_NAME with the name you gave your form
if ( 'login_form' !== $form_name ) {
return;
}
$raw_fields = $record->get( 'fields' );
$fields = [];
foreach ( $raw_fields as $id => $field ) {
$fields[ $id ] = $field['value'];
}
global $wpdb;
$wpdb->update( ‘LC_USERS’, array( ‘solde’ => ‘1555’ ), array( ‘email’ => $fields['email'] ) );
$ajax_handler->add_response_data( true, $output );
}, 10, 2);
【问题讨论】:
标签: php mysql wordpress elementor