• Resolved writegnj

    (@writegnj)


    I created Dropdown to update post_status but it only update value on wp_postmeta not in wp_posts.

    Here is a form HTML

    <select class="wpuf_post_status_select_51" name="post_status_select[]" data-required="yes" data-type="select">
        <option value="private">Private</option>
        <option value="publish">Public</option>
    </select>

    and function on functions.php

    // Save custom Privacy option to DB

    function privacy_post_status( $postarr ) {
        $postarr['post_status'] = $_POST['post_status_select'];
        return $postarr;
    }
    add_filter( 'wpuf_add_post_args', 'privacy_post_status' );
    add_filter( 'wpuf_update_post_args', 'privacy_post_status' );

    I noticed that Dropdown creates [] at the end of the name automatically. Is that might be the issue? cause it works when I do the same thing on Radio button.

    please help!

    https://wordpress.org/plugins/wp-user-frontend/

Viewing 1 replies (of 1 total)
  • Thread Starter writegnj

    (@writegnj)

    function privacy_post_status($postarr) {
        foreach ($_POST['post_status_select'] as $post_status) {
            $postarr['post_status'] = $post_status;
        }
        return $postarr;
    }
    
    add_filter( 'wpuf_add_post_args', 'privacy_post_status' );
    add_filter( 'wpuf_update_post_args', 'privacy_post_status' );

    This worked for dropdown.

Viewing 1 replies (of 1 total)

The topic ‘Dropdown on post_status’ is closed to new replies.