I want to create a custom database table when activate my plugin. Could you please give me a sample code for create a simple database table.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To create a custom database table in WordPress when activating a plugin, add the following code in plugin file.
register_activation_hook
function will be triggered when plugin is activateddbDelta
function is used to create the table.custom_table
with your desired table name, andcolumn1
andcolumn2
with your desired column names.