Making WordPress.org


Ignore:
Timestamp:
07/25/2014 12:24:11 AM (11 years ago)
Author:
iandunn
Message:

WordCamp Post Type: Require an e-mail address before setting as pending.

There are automated emails that get sent when the post is promoted to a pending status, so we need an e-mail
address at that time or we can't send them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php

    r759 r761  
    502502
    503503    /**
    504      * Prevent WordCamp posts from being published until all the required fields are completed.
     504     * Prevent WordCamp posts from being set to pending or published until all the required fields are completed.
    505505     *
    506506     * @param array $post_data
     
    512512        $min_site_id = apply_filters( 'wcpt_require_complete_meta_min_site_id', '2416297' );
    513513
    514         $required_fields = array(
     514        $required_pending_fields = array( 'E-mail Address' );
     515
     516        $required_publish_fields = array(
    515517            // WordCamp
    516518            'Start Date (YYYY-mm-dd)',
     
    539541        );
    540542
     543        // Check pending posts
     544        if ( WCPT_POST_TYPE_ID == $post_data['post_type'] && 'pending' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) {
     545            foreach( $required_pending_fields as $field ) {
     546                $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ];
     547
     548                if ( empty( $value ) || 'null' == $value ) {
     549                    $post_data['post_status']     = 'draft';
     550                    $this->active_admin_notices[] = 3;
     551                    break;
     552                }
     553            }
     554        }
     555
     556        // Check published posts
    541557        if ( WCPT_POST_TYPE_ID == $post_data['post_type'] && 'publish' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) {
    542             foreach( $required_fields as $field ) {
     558            foreach( $required_publish_fields as $field ) {
    543559                $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ];
    544560
     
    609625                    $post->post_status
    610626                )
     627            ),
     628
     629            3 => array(
     630                'type'   => 'error',
     631                'notice' => __( 'This WordCamp cannot be set to pending until all of its required metadata is filled in.', 'wordcamporg' ),
    611632            ),
    612633        );
Note: See TracChangeset for help on using the changeset viewer.