WordPress.org

Support

Support » Plugins and Hacks » WP User Frontend » Make upload featured image a required field

Make upload featured image a required field

  • Hello and thank you very much for this great plugin !

    I need people who posting on my web site to upload a featured image for each post they make. I just try to make the featured image option a absolutely required field to avoid posting without them. Please advice me on a way to achieve that. Thanks in advance.

    http://wordpress.org/extend/plugins/wp-user-frontend/

Viewing 6 replies - 1 through 6 (of 6 total)
  • This isnt that easy unlike input text fields.

    The easiest way to do it is to add the red required * to the featured image label and use the class=”requiredField” attribute on the “UploadImage” button with javascript updates

    Change

    <label for="post-thumbnail"><?php echo wpuf_get_option( 'ft_image_label' ); ?></label>
    <div id="wpuf-ft-upload-container">
    <div id="wpuf-ft-upload-filelist"></div>
    <a id="wpuf-ft-upload-pickfiles" class="button" href="#"><?php echo wpuf_get_option( 'ft_image_btn_label' ); ?></a>

    to

    <label for="post-thumbnail"><?php echo wpuf_get_option( 'ft_image_label' ); ?> <span class="required">*</span></label>
    <div id="wpuf-ft-upload-container">
    <div id="wpuf-ft-upload-filelist"></div>
    <a id="wpuf-ft-upload-pickfiles" class="button requiredField" href="#"><?php echo wpuf_get_option( 'ft_image_btn_label' ); ?></a>

    Then add code to the featImgUploader and removeFeatImg functions in wpuf.js to check for that a featured image is present and remove/add the class=”requiredField” to the “UploadImage” button to suit.

    Hello professor99,
    I am trying to add this function to the fork 2RRR_4_3.
    Could you give more details on how to implement this code to featImgUploader and featured_image.js ?
    Thanks

    Hi JDking,

    For the fork I don’t think you have to do anything in featured_image.js. It is really a submit check which is performed by the checkSubmit function in wpuf.js and the code needed is described in the previous article.

    Other than that you just have to edit the function add_post_fields() in the file featured_image.php to add the classes “required” and “requiredField” much the same as described in the previous article.

    Hi professor99

    Then add code to the featImgUploader and removeFeatImg functions in wpuf.js to check for that a featured image is present and remove/add the class=”requiredField” to the “UploadImage” button to suit.

    How to this?

    I think my grammar needs improving :).

    Improved version:

    Then you need to add code to the featImgUploader() and removeFeatImg() functions in wpuf.js to check that a featured image is present . Then add or remove the class “requiredField” from the “UploadImage” button to suit.

    To check if a image is present look at the div wpuf-ft-upload-filelist. If it is empty then no image is present.

    If you can’t code it yourself you can get the Pro version which already does this.

    nyan-nyan

    @nyan-nyan

    I’m sorry for late reply…

    I bought Pro version.
    It’s cool!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Make upload featured image a required field’ is closed to new replies.
Skip to toolbar