admin管理员组文章数量:1277336
Hi I just copied some code to change a post custom field term by clicking on the btn with #projects-pay-btn id and work with it on frontend as end user, but it does not working. when the user push the btn to pay, I want to change the field named = project_status change to the new value. There is the code, I hope someone could help me out.
function change_payment_status(){
$post_id = $_POST['post_id'];
global $wpdb;
$tbl = $wpdb->prefix."posts";
$taxonomies = array( 'project_status');
$statname = array(
'name' => 'در انتظار تایید پرداخت',
'slug' => 'payment_accept'
) ;
try{
wp_set_object_terms( $post_id, $statname, $taxonomies, $append = false );
}
catch(Exception $e){}
echo json_encode($res);
die();
}
global $post;
global $wp;
echo '
<script>
var cur_url = "'.home_url( $wp->request ).'";
var ajx_url = "'.admin_url('admin-ajax.php').'";
var post_id = "'.$post->ID.'";
jQuery(document).ready(function(){
jQuery("#projects-pay-btn").submit(function(e){
jQuery.post(ajx_url,{action:"change_payment_status",post_id:post_id},function(data){
var arr = JSON.parse(data);
});
}
return false;
);
});
</script>
';
本文标签: functionswpsetobjectterm via js btn frontend
版权声明:本文标题:functions - wp_set_object_term via js btn frontend 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741249557a2365536.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论