wordpress - Function to create a Category for each Group (BuddyPress) on creation -
I have a category created for each BuddyPress group when it is created so far I have received this code, Made a category that was made. I will use this code in theme functions
function example_insert_category () {wp_insert_term ('example category name', 'category', array ('description' = & gt; 'this is an example category'., 'Slug' = & Gt; 'example-category-slug'); } Add_action ('groups_group_create_complete', 'example_insert_category'); At first I am on the right track. Second, how would I use the newly created group's name and group slug category name and grade slug?
function example_insert_category ($ group_id) { $ Group = groups_get_group (array ('group_id' = & gt; $ group_id)) // var_dump ($ group); wp_insert_term ($ group-> name, 'category', array ('description' = & gt; $ Group- & gt; description, 'slug' = & gt; $ group- & gt; slug))} Add_action ('groups_group_create_complete', 'example_insert_category');
Comments
Post a Comment