Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m trying to do the same… professor is helping here: http://wordpress.org/support/topic/plugin-wp-user-frontend-select-post-format?replies=10

    Also Tareq seems to mention it can work with filters here: http://tareq.wedevs.com/2012/04/how-to-extend-wp-user-frontend/comment-page-1/#comment-4381

    I was finally able to create a drop down to set post format using the hooks provided by Tareq and wanted to share my code in case it can be of use to anyone.

    Paste the following in your functions.php

    // Add the drop-down (you can edit the list of post format options)
    function wpufe_content_type( $post_type, $post = null) {
    
        ?>
        <li>
            <label for="post_format">Content Type<span class="required">*</span></label>
            <select class="requiredField" name="content_type" id="content_type">
            	<option value="" selected="selected">What are you posting?</option>
                <option value="standard">Text (Blog Post)</option>
                <option value="image">Single Image</option>
                <option value="gallery">Gallery of Images</option>
                <option value="video">Video</option>
                <option value="audio">Audio</option>
            </select>
            <div class="clear"></div>
        </li>
        <?php
    }
    
    add_action( 'wpuf_add_post_form_top', 'wpufe_content_type', 10, 2 );
    
    // Validate the data (optional)
    function wpufe_content_type_validation( $errors ) {
        if( $_POST['content_type'] == '' ) {
            $errors[] = 'Please select a Content Type.';
        }
    
        return $errors;
    }
    add_filter( 'wpuf_add_post_validation', 'wpufe_content_type_validation' );
    
    // Make it happen!
    function wpufe_add_content_type( $post_id ) {
    	set_post_format( $post_id, $_POST['content_type'] );
    }
    add_action( 'wpuf_add_post_after_insert', 'wpufe_add_content_type' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP User Frontend] Set post_format when adding post?’ is closed to new replies.