Home Forums Plugin Support WP User Frontend Pro Hidden Category

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Sparhamster 6 years, 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2012

    Sparhamster
    Participant
    Post count: 22

    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 ๐Ÿ˜‰

    #2014

    Tareq Hasan
    Keymaster
    Post count: 2831

    Here you go

    #2042

    Sparhamster
    Participant
    Post count: 22

    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.

    #2063

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #2071

    Sparhamster
    Participant
    Post count: 22

    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โ€ณ); ?

    #2077

    Tareq Hasan
    Keymaster
    Post count: 2831

    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]

    #2104

    Sparhamster
    Participant
    Post count: 22

    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 7 posts - 1 through 7 (of 7 total)

The topic ‘Hidden Category’ is closed to new replies.