Example #1
0
    ?>
                </div>
                <p class="btn-warpper-bid">
                <?php 
    if (!$user_ID && $project_status == 'publish') {
        ?>
                        <a href="#"  class="btn-apply-project-item btn-login-trigger btn-bid btn-bid-mobile" ><?php 
        _e('Bid', ET_DOMAIN);
        ?>
</a>
                        <?php 
    } else {
        $role = ae_user_role();
        if ($project_status == 'publish') {
            if ($role == FREELANCER) {
                $has_bid = fre_has_bid(get_the_ID());
                if ($has_bid) {
                    ?>
                                    <a rel="<?php 
                    echo $project->ID;
                    ?>
" href="#" id="<?php 
                    echo $has_bid;
                    ?>
" title= "<?php 
                    _e('Delete this bidding', ET_DOMAIN);
                    ?>
"  class="btn-bid btn-del-project" ><?php 
                    _e('Cancel', ET_DOMAIN);
                    ?>
</a>
Example #2
0
 function fre_check_before_insert_bid($args)
 {
     global $user_ID;
     /**
      * add filter to filter bid required field
      * @param Array
      * @since 1.4
      * @author Dakachi
      */
     $bid_required_field = apply_filters('fre_bid_required_field', array('bid_budget', 'bid_time', 'bid_content'));
     if (is_wp_error($args)) {
         return $args;
     }
     if (in_array('bid_content', $args) && !isset($args['bid_content'])) {
         return new WP_Error('empty_content', __('Please enter your bid message.', ET_DOMAIN));
     }
     $args['post_content'] = $args['bid_content'];
     $project_id = isset($args['post_parent']) ? $args['post_parent'] : '';
     $args['post_status'] = 'publish';
     // $request = $_POST;
     /*
      * validate data
      */
     if (in_array('bid_budget', $bid_required_field) && (!isset($args['bid_budget']) || empty($args['bid_budget']))) {
         return new WP_Error('empty_bid', __('You have to set the bid budget.', ET_DOMAIN));
     }
     if (in_array('bid_time', $bid_required_field) && (!isset($args['bid_time']) || empty($args['bid_time']))) {
         return new WP_Error('empty_time', __('You have to set the time to finish project.', ET_DOMAIN));
     }
     if (in_array('bid_budget', $bid_required_field) && $args['bid_budget'] <= 0) {
         return new WP_Error('budget_less_than_zero', __("Your budget have to greater than zero!", ET_DOMAIN));
     }
     if (in_array('bid_budget', $bid_required_field) && !is_numeric($args['bid_budget']) || in_array('bid_time', $bid_required_field) && !is_numeric($args['bid_time'])) {
         return new WP_Error('invalid_input', __('Please enter a valid number in budget or bid time', ET_DOMAIN));
     }
     if (!$user_ID) {
         return new WP_Error('no_permission', __('Please login to bid a project', ET_DOMAIN));
     }
     if (get_post_status($project_id) != 'publish') {
         return new WP_Error('invalid_input', __('This project is not publish.', ET_DOMAIN));
     }
     // $accepted = get_post_meta($project_id,'accepted', true);
     // if($accepted || 'complete' ==  get_post_status($project_id) )
     //    return new  WP_Error (200 ,__('The project has been accepted', ET_DOMAIN));
     if (fre_has_bid($project_id)) {
         return new WP_Error(200, __('You have bid on this project', ET_DOMAIN));
     }
     $post_author = (int) get_post_field('post_author', $project_id, 'display');
     if ($user_ID == $post_author) {
         return new WP_Error(200, __('You can\'t bid on your project', ET_DOMAIN));
     }
     // check role to bid project
     $role = ae_user_role();
     if (!fre_share_role() && $role != FREELANCER) {
         return new WP_Error(200, __('You have to be a freelancer to bid a project.', ET_DOMAIN));
     }
     /*
      * check profile has set?
      */
     $profile_id = get_user_meta($user_ID, 'user_profile_id', true);
     $profile = get_post($profile_id);
     // user have to complete profile to bid a project
     if (!$profile || !is_numeric($profile_id)) {
         return new WP_Error(200, __('You must complete your profile to bid on a project.', ET_DOMAIN));
     }
     /* when using escrow, freelancer must setup an paypal account */
     $stripe_api = ae_get_option('escrow_stripe_api');
     if (ae_get_option('use_escrow') && (!$stripe_api || !$stripe_api['use_stripe_escrow'])) {
         $paypal_account = get_user_meta($user_ID, 'paypal', true);
         if (!$paypal_account) {
             return new WP_Error('dont_have_paypal', __('You must setup your paypal account in profile to receive money.', ET_DOMAIN));
         }
     }
     return $args;
 }