How can I call a php file inside a wordpress plugin

Asked

Viewed 175 times

0

How can I create a file within a wordpress plugin to receive parameters passed via front post? the file would need to use the wp_db function.

1 answer

0

You can use admin_post_(action).

When you create your form in front-end you add the input

<input type="hidden" name="action" value="nome_da_funcao">

Inside your plugin you add the Hooks

add_action( 'admin_post_nome_da_funcao', 'my_function' );
add_action( 'admin_post_nopriv_nome_da_funcao', 'my_function' );


function my_function() {
//Seus codigos e request aqui

}

https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action) http://www.adaptiveweb.com.au/handle-post-and-get-requests-in-wordpress-using-admin-post-php/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.