Hidden Category

This topic contains 6 reply and 2 voices, and was last updated by Sparhamster 11 years ago
Viewing 6 Posts - 1 through 6 (of 6 total)
Author Posts
April 11, 2013 at 12:00 am 2012
Sparhamster I have 2 different forms. each of that forms is for one category which has to be in the database. the user shouldn't be allowed to uncheck it. i used TDO Mini Forms before and there was a possibility to set a default category. if u tell me the code line before u insert it into the database, i will add it for myself ;)
April 11, 2013 at 12:49 am 2014
Tareq Hasan Tareq Hasan

Here you go

April 11, 2013 at 12:55 pm 2042
Sparhamster Sparhamster

the category has to be additional to the selected categories.

for example: category 23, 56 and 117 are selected. category 1 has to be added.

April 12, 2013 at 1:33 am 2063
Tareq Hasan Tareq Hasan

So your form will have category dropdown or checkbox. But you want to add an additional category automatically after the post has been submitted?

April 12, 2013 at 4:47 am 2071
Sparhamster Sparhamster

Yes my form have checkbox for category.

“But you want to add an additional category automatically after the post has been submitted?” -> Yes i do 😉

array_push($_POST[‘Category’], “1″); ?

April 12, 2013 at 10:27 am 2077
Tareq Hasan Tareq Hasan

You should be trying like this:
[php]
function wpufe_add_category( $postarr ) {
if ( isset( $postarr[‘post_category’] ) ) {
array_push( $postarr[‘post_category’], 1);
}
}

add_filter( ‘wpuf_add_post_args’, ‘wpufe_add_category’ );
[/php]

April 12, 2013 at 3:19 pm 2104
Sparhamster Sparhamster

Thx a lot.. but u forgot the return value 😉

function wpufe_add_category( $postarr ) {
if ( isset( $postarr[‘post_category’] ) ) {
array_push( $postarr[‘post_category’], 1);
}
return $postarr;
}

worked 😉

Viewing 6 Posts - 1 through 6 (of 6 total)