can we store custom option field in custom data base table

Question

Hi i just want to know can we store the value of a custom created option in my custom database table? If yes then how?

do I need to edit register_setting()

Here is my code i want to save this in table named wp_ldc_user please help me with this

register_setting(
    'ldc_settings', 
    'ldc_username',
    'sanitize_text_field'
);

add_settings_field(
    'ldc_username',
    'Username',
     array($this,'ldc_text_field_html'), 
    'ldc_quize', 
    'ldc_settings_section', 
    array( 
        'label_for' => 'ldc_username', 
    )
);

function ldc_text_field_html(){
 
   $text = get_option( 'ldc_username' );
 
   printf(
       '<input type="text" id="ldc_username" name="ldc_username" value="%s" />',
       esc_attr( $text )
    );
 
 }
0
Mohit 8 months 2020-12-01T00:10:32-05:00 0 Answers 8 views 0

Leave an answer

Browse
Browse