2017-02-20 5 views
1

WordPressで新しい投稿タグを作成することによってトリガされるWordPressで関数を呼び出そうとしています。新しいタグがWordPressで作成された場合に関数を呼び出す

問題があるのはアクションコールです。最初はこのadd_action('edit_tag_form', 'update_tags',10 ,2);を使用しようとしましたが、読んだ後にWordPressがこのアクションコールを解凍したことを知っています。 then これでこれを達成しようとしましたが、うまくいきません。

何か助けていただければ幸いです。

function update_tags($ID, $tags) { 
$data = array("name" => $tags->name,"slug" => $tags->slug); 

$data_string = json_encode($data);                     

$ch = curl_init('ANY API');                  
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                  
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                  
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                   
    'Content-Type: application/json',                     
    'Content-Length: ' . strlen($data_string))                  
);                             

$result = curl_exec($ch); 
} 
add_action('post_tag_edit_form', 'update_tags',10 ,2); 

答えて

1

あなたは新しいフックを使用することができるはずのようになります。ご返信用https://developer.wordpress.org/reference/hooks/taxonomy_add_form/

+0

こんにちはおかげで、それは細かい add_action(「post_tag_add_formを働いた:

{$taxonomy}_add_form 

は、参照をチェック'、' update_tags '、10,2); あなたは私が$ tags-> nameと$ tags-> slugを得ることができないと伝えることができます 実際にはタグも取得されませんタグ名とタグスラッグ –

+0

get_the_tags()関数。 [https://codex.wordpress.org/Function_Reference/get_the_tags](https://codex.wordpress.org/Function_Reference/get_the_tags) – dpjas

関連する問題