php - Wordpress custom submit button -
i'm getting little lost :d
short explanation:
i want able process $_post data when submit button clicked on custom post type. firstly how or function can use add custom input submit, , secondly how can build function submitting of button? can't seem find solution anywhere!
long explanation:
i'm building authorisation paypal system custom post type named orders. have orders in table access using class. have payment information , know have capture payment, want button able , return errors. want separate button 'update' , method of capturing action can api call etc.
i don't want plugin. need know how make input , use $_post.
can custom meta box?
add_meta_box('order_payment','build_order_payment_info','orders','side'); function build_order_payment_info($post){ <input name="id" type="hidden" value="id of payment"> <input name="other info needed" type="hidden" value=""> <input name="submitpayment" type="submit" value="process payment"> }
then in order meta
add_action('save_post','save_order'); function save_order(){ global$post; if(isset($_post['submitpayment'])&&!empty($_post['id'])){ //send payment api }else echo"there error payment"; }
would work? i've read can provide custom post type add_action function this: 'save_post_orders', correct?
if understand right, want input fields , button sends values inputs file on server , file should it?
if thats case, can on 2 ways:
1 - old submit button
2 - bind ajax call element
examples:
1: http://www.w3schools.com/tags/att_button_form.asp
2: http://api.jquery.com/jquery.ajax/
well rest script on server side (http://php.net/manual/en/reserved.variables.post.php)
note 2: @ bottom examples, easier understand if you've never done before
Comments
Post a Comment