WordPress.org

Ready to get started?Download WordPress

Forums

WP User Frontend
Make upload featured image a required field (7 posts)

  1. devnst
    Member
    Posted 1 year ago #

    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/

  2. professor99
    Member
    Posted 1 year ago #

    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.

  3. JDking
    Member
    Posted 1 year ago #

    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

  4. professor99
    Member
    Posted 1 year ago #

    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.

  5. nyan-nyan
    Member
    Posted 1 year ago #

    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?

  6. professor99
    Member
    Posted 1 year ago #

    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.

  7. nyan-nyan
    Member
    Posted 7 months ago #

    I'm sorry for late reply...

    I bought Pro version.
    It's cool!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.