当前位置: 首页>>代码示例>>PHP>>正文


PHP edd_set_error函数代码示例

本文整理汇总了PHP中edd_set_error函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_set_error函数的具体用法?PHP edd_set_error怎么用?PHP edd_set_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了edd_set_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: kfg_check_if_is_renewal

function kfg_check_if_is_renewal($return)
{
    if (EDD()->session->get('edd_is_renewal')) {
        edd_set_error('edd-discount-error', __('This discount is not valid with renewals.', 'edd'));
        return false;
    }
    return $return;
}
开发者ID:mintplugins,项目名称:library,代码行数:8,代码来源:prevent-discounts-with-sl-renewals.php

示例2: discount_validation

 public function discount_validation($data)
 {
     if ($data['discount'] == 'none' || empty($data['discount'])) {
         $options = get_option('foa_edd_force_discount', '');
         $errornotice = empty($options['errornotice']) ? __('Discount code is a required field. Please enter a discount code.', 'edd-force-discount') : $options['errornotice'];
         edd_set_error('efdfoa_error_notice', $errornotice);
     }
 }
开发者ID:kowsar89,项目名称:edd-force-discount,代码行数:8,代码来源:class-edd-force-discount.php

示例3: sumobi_edd_set_minimum_password_length

function sumobi_edd_set_minimum_password_length($valid_data, $post_data)
{
    // how many characters should the password be?
    $length = 8;
    if (strlen($post_data['edd_user_pass']) < $length) {
        edd_set_error('password_too_short', sprintf(__('Please enter a password of %s characters or more.', 'edd'), $length));
    }
}
开发者ID:mintplugins,项目名称:library,代码行数:8,代码来源:force-minimum-password-length.php

示例4: pw_edd_prevent_duplicate_purchase

/**
 * Prevents logged-in customers from purchasing an item twice
 *
 */
function pw_edd_prevent_duplicate_purchase($valid_data, $posted)
{
    $cart_contents = edd_get_cart_contents();
    foreach ($cart_contents as $item) {
        if (edd_has_user_purchased(get_current_user_id(), $item['id'])) {
            edd_set_error('duplicate_item', 'You have already purchased this item so may not purchase it again');
        }
    }
}
开发者ID:mintplugins,项目名称:library,代码行数:13,代码来源:prevent-duplicate-purchases.php

示例5: edd_no_gateway_error

/**
 * Sets an error on checkout if no gateways are enabled
 *
 * @since 1.3.4
 * @return void
 */
function edd_no_gateway_error()
{
    $gateways = edd_get_enabled_payment_gateways();
    if (empty($gateways)) {
        edd_set_error('no_gateways', __('You must enable a payment gateway to use Easy Digital Downloads', 'edd'));
    } else {
        edd_unset_error('no_gateways');
    }
}
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:15,代码来源:actions.php

示例6: edd_acq_validate_custom_fields

/**
 * Validates the survey results on checkout
 *
 * @since  1.0
 * @param  array $valid_data The array of valid data
 * @param  array $data       The data submitted
 * @return void
 */
function edd_acq_validate_custom_fields($valid_data, $data)
{
    $methods = edd_acq_get_methods();
    if (empty($methods)) {
        return;
    }
    $required = edd_get_option('acq_require_response', false);
    if ($required && (empty($data['edd_acquisition_method']) || $data['edd_acquisition_method'] == '-1')) {
        // check for a phone number
        edd_set_error('invalid_acquisition_method', __('Please tell us how you found us.', 'edd-acquisition-survey'));
    }
}
开发者ID:SelaInc,项目名称:eassignment,代码行数:20,代码来源:functions.php

示例7: pw_edd_recurring_limit_one_subscription

function pw_edd_recurring_limit_one_subscription($valid_data, $post_data)
{
    if (!class_exists('EDD_Recurring_Customer')) {
        return;
    }
    if (!is_user_logged_in()) {
        return;
    }
    $purchase_data = array('downloads' => edd_get_cart_contents());
    if (EDD_Recurring_Customer::is_customer_active() && EDD_Recurring()->is_purchase_recurring($purchase_data)) {
        edd_set_error('edd-one-subscription', __('You already have an active subscription so may not purchase a second one.', 'edd'));
    }
}
开发者ID:mintplugins,项目名称:library,代码行数:13,代码来源:one-subscription.php

示例8: edd_email_domain_validation

 public function edd_email_domain_validation($data)
 {
     // return if email doesn't exists
     if (empty($data['logged_in_user']['user_email']) && empty($data['guest_user_data']['user_email'])) {
         return;
     }
     $email = empty($data['logged_in_user']['user_email']) ? $data['guest_user_data']['user_email'] : $data['logged_in_user']['user_email'];
     $email = trim($email);
     // return if email is unvalid
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return;
     }
     $error = $this->verify_email($email);
     // show error notice for blacklisted emails
     if ($error) {
         edd_set_error('wedb_blacklisted_email', $error);
     }
 }
开发者ID:kowsar89,项目名称:woo-email-domain-blacklist,代码行数:18,代码来源:email-blacklist.php

示例9: checkout_errors

 /**
  * Ensure out of stock tickets cannot be purchased even if they manage to get added to the cart
  */
 public function checkout_errors()
 {
     foreach ((array) edd_get_cart_contents() as $item) {
         $remaining = $this->stock_control->available_units($item['id']);
         // We have to append the item IDs otherwise if we have multiple errors of the same type one will overwrite
         // the other
         if (!$remaining) {
             edd_set_error('no_stock_' . $item['id'], sprintf(__('%s ticket is sold out', 'event-tickets-plus'), get_the_title($item['id'])));
         } elseif (self::UNLIMITED !== $remaining && $item['quantity'] > $remaining) {
             edd_set_error('insufficient_stock_' . $item['id'], sprintf(__('Sorry! Only %d tickets remaining for %s', 'event-tickets-plus'), $remaining, get_the_title($item['id'])));
         }
     }
 }
开发者ID:jamestrevorlees,项目名称:odd-web-v1.00,代码行数:16,代码来源:Main.php

示例10: edd_get_purchase_link

/**
 * Get Purchase Link
 *
 * Builds a Purchase link for a specified download based on arguments passed.
 * This function is used all over EDD to generate the Purchase or Add to Cart
 * buttons. If no arguments are passed, the function uses the defaults that have
 * been set by the plugin. The Purchase link is built for simple and variable
 * pricing and filters are available throughout the function to override
 * certain elements of the function.
 *
 * $download_id = null, $link_text = null, $style = null, $color = null, $class = null
 *
 * @since 1.0
 * @param array $args Arguments for display
 * @return string $purchase_form
 */
function edd_get_purchase_link($args = array())
{
    global $post, $edd_displayed_form_ids;
    $purchase_page = edd_get_option('purchase_page', false);
    if (!$purchase_page || $purchase_page == 0) {
        edd_set_error('set_checkout', sprintf(__('No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'easy-digital-downloads'), admin_url('edit.php?post_type=download&page=edd-settings')));
        edd_print_errors();
        return false;
    }
    $post_id = is_object($post) ? $post->ID : 0;
    $button_behavior = edd_get_download_button_behavior($post_id);
    $defaults = apply_filters('edd_purchase_link_defaults', array('download_id' => $post_id, 'price' => (bool) true, 'price_id' => isset($args['price_id']) ? $args['price_id'] : false, 'direct' => $button_behavior == 'direct' ? true : false, 'text' => $button_behavior == 'direct' ? edd_get_option('buy_now_text', __('Buy Now', 'easy-digital-downloads')) : edd_get_option('add_to_cart_text', __('Purchase', 'easy-digital-downloads')), 'style' => edd_get_option('button_style', 'button'), 'color' => edd_get_option('checkout_color', 'blue'), 'class' => 'edd-submit'));
    $args = wp_parse_args($args, $defaults);
    // Override the stright_to_gateway if the shop doesn't support it
    if (!edd_shop_supports_buy_now()) {
        $args['direct'] = false;
    }
    $download = new EDD_Download($args['download_id']);
    if (empty($download->ID)) {
        return false;
    }
    if ('publish' !== $download->post_status && !current_user_can('edit_product', $download->ID)) {
        return false;
        // Product not published or user doesn't have permission to view drafts
    }
    // Override color if color == inherit
    $args['color'] = $args['color'] == 'inherit' ? '' : $args['color'];
    $options = array();
    $variable_pricing = $download->has_variable_prices();
    $data_variable = $variable_pricing ? ' data-variable-price="yes"' : 'data-variable-price="no"';
    $type = $download->is_single_price_mode() ? 'data-price-mode=multi' : 'data-price-mode=single';
    $show_price = $args['price'] && $args['price'] !== 'no';
    $data_price_value = 0;
    $price = false;
    if ($variable_pricing && false !== $args['price_id']) {
        $price_id = $args['price_id'];
        $prices = $download->prices;
        $options['price_id'] = $args['price_id'];
        $found_price = isset($prices[$price_id]) ? $prices[$price_id]['amount'] : false;
        $data_price_value = $found_price;
        if ($show_price) {
            $price = $found_price;
        }
    } elseif (!$variable_pricing) {
        $data_price_value = $download->price;
        if ($show_price) {
            $price = $download->price;
        }
    }
    $args['display_price'] = $data_price_value;
    $data_price = 'data-price="' . $data_price_value . '"';
    $button_text = !empty($args['text']) ? '&nbsp;&ndash;&nbsp;' . $args['text'] : '';
    if (false !== $price) {
        if (0 == $price) {
            $args['text'] = __('Free', 'easy-digital-downloads') . $button_text;
        } else {
            $args['text'] = edd_currency_filter(edd_format_amount($price)) . $button_text;
        }
    }
    if (edd_item_in_cart($download->ID, $options) && (!$variable_pricing || !$download->is_single_price_mode())) {
        $button_display = 'style="display:none;"';
        $checkout_display = '';
    } else {
        $button_display = '';
        $checkout_display = 'style="display:none;"';
    }
    // Collect any form IDs we've displayed already so we can avoid duplicate IDs
    if (isset($edd_displayed_form_ids[$download->ID])) {
        $edd_displayed_form_ids[$download->ID]++;
    } else {
        $edd_displayed_form_ids[$download->ID] = 1;
    }
    $form_id = !empty($args['form_id']) ? $args['form_id'] : 'edd_purchase_' . $download->ID;
    // If we've already generated a form ID for this download ID, apped -#
    if ($edd_displayed_form_ids[$download->ID] > 1) {
        $form_id .= '-' . $edd_displayed_form_ids[$download->ID];
    }
    $args = apply_filters('edd_purchase_link_args', $args);
    ob_start();
    ?>
	<form id="<?php 
    echo $form_id;
    ?>
" class="edd_download_purchase_form edd_purchase_<?php 
//.........这里部分代码省略.........
开发者ID:jplhomer,项目名称:Easy-Digital-Downloads,代码行数:101,代码来源:template-functions.php

示例11: edd_process_profile_editor_updates

/**
 * Process Profile Updater Form
 *
 * Processes the profile updater form by updating the necessary fields
 *
 * @since 1.4
 * @author Sunny Ratilal
 * @param array $data Data sent from the profile editor
 * @return void
 */
function edd_process_profile_editor_updates($data)
{
    // Profile field change request
    if (empty($_POST['edd_profile_editor_submit']) && !is_user_logged_in()) {
        return false;
    }
    // Nonce security
    if (!wp_verify_nonce($data['edd_profile_editor_nonce'], 'edd-profile-editor-nonce')) {
        return false;
    }
    $user_id = get_current_user_id();
    $display_name = sanitize_text_field($data['edd_display_name']);
    $first_name = sanitize_text_field($data['edd_first_name']);
    $last_name = sanitize_text_field($data['edd_last_name']);
    $email = sanitize_email($data['edd_email']);
    $userdata = array('ID' => $user_id, 'first_name' => $first_name, 'last_name' => $last_name, 'display_name' => $display_name, 'user_email' => $email);
    // New password
    if (!empty($data['edd_new_user_pass1'])) {
        if ($data['edd_new_user_pass1'] !== $data['edd_new_user_pass2']) {
            edd_set_error('password_mismatch', __('The passwords you entered do not match. Please try again.', 'edd'));
        } else {
            $userdata['user_pass'] = $data['edd_new_user_pass1'];
        }
    }
    // Update the user
    $updated = wp_update_user($userdata);
    if ($updated) {
        do_action('edd_user_profile_updated', $user_id, $userdata);
        wp_redirect(add_query_arg('updated', 'true', $data['edd_redirect']));
        edd_die();
    }
}
开发者ID:bangtienmanh,项目名称:Easy-Digital-Downloads,代码行数:42,代码来源:shortcodes.php

示例12: __triggerError

 /**
  * Internal error handler
  *
  * @internal Internal error handler
  * @param string $message Error message
  * @param string $file Filename
  * @param integer $line Line number
  * @param integer $code Error code
  * @return void
  */
 private static function __triggerError($message, $file, $line, $code = 0)
 {
     edd_set_error('edd-amazon-s3', $message . ' - ' . $file . ':' . $line . "\n" . 'Code: ' . $code);
 }
开发者ID:Rexix,项目名称:edd-amazon-s3,代码行数:14,代码来源:s3.php

示例13: process_payment

 /**
  * Process payment submission
  *
  * @access      public
  * @since       1.0.0
  * @param       array $purchase_data The data for a specific purchase
  * @return      void
  */
 public function process_payment($purchase_data)
 {
     if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'edd-gateway')) {
         wp_die(__('Nonce verification has failed', 'edd-wallet'), __('Error', 'edd-wallet'), array('response' => 403));
     }
     $error = false;
     // Double check that we can afford this item
     $value = edd_wallet()->wallet->balance($purchase_data['user_email']);
     if ($value < $purchase_data['price']) {
         edd_record_gateway_error(__('Wallet Gateway Error', 'edd-wallet'), __('User wallet has insufficient funds.', 'edd-wallet'), 0);
         edd_set_error('wallet_error', __('Insufficient funds.', 'edd-wallet'));
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     }
     $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => edd_get_currency(), 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending');
     // Record the pending payment
     $payment = edd_insert_payment($payment_data);
     if ($payment) {
         // Update payment status
         edd_update_payment_status($payment, 'publish');
         // Withdraw the funds
         edd_wallet()->wallet->withdraw($purchase_data['user_info']['id'], $payment_data['price'], 'withdrawal', $payment);
         edd_empty_cart();
         edd_send_to_success_page();
     } else {
         edd_record_gateway_error(__('Wallet Gateway Error', 'edd-wallet'), sprintf(__('Payment creation failed while processing a Wallet purchase. Payment data: %s', 'edd-wallet'), json_encode($payment_data)), $payment);
         edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']);
     }
 }
开发者ID:easydigitaldownloads,项目名称:edd-wallet,代码行数:36,代码来源:class.edd-wallet-gateway.php

示例14: edd_slg_process_profile

 /**
  * Process Profile
  * 
  * Handles to process social profile
  * 
  * @package Easy Digital Download - Social Login
  * @since 1.5.6
  */
 public function edd_slg_process_profile($data = array())
 {
     global $wpdb;
     $user = null;
     $new_customer = false;
     $found_via = null;
     $message = edd_slg_messages();
     if (!empty($data) && !empty($data['type'])) {
         //social provider type
         $type = $data['type'];
         $identifier = $data['id'];
         // First, try to identify user based on the social identifier
         $user_id = $wpdb->get_var($wpdb->prepare('SELECT user_id FROM ' . $wpdb->usermeta . ' WHERE ( meta_key = "%1$s" AND meta_value = "%2$s" || meta_key = "%3$s" AND meta_value = "%2$s" )', 'edd_slg_social_' . $type . '_identifier', $identifier, 'edd_slg_social_identifier'));
         if ($user_id) {
             $user = get_user_by('id', $user_id);
             $found_via = 'social_identifier';
         }
         // Fall back to email - user may already have an account with the same email as in their social profile
         if (!$user && !empty($data['email'])) {
             $user = get_user_by('email', $data['email']);
             $found_via = 'email';
         }
         if (is_user_logged_in()) {
             // If a user is already logged in
             // check that the logged in user and found user are the same.
             // This happens when user is linking a new social profile to their account.
             if ($user && get_current_user_id() !== $user->ID) {
                 if ($found_via == 'social_identifier') {
                     $already_linked_error = isset($message['already_linked_error']) ? $message['already_linked_error'] : '';
                     return edd_set_error('edd_slg_account_already_linked', $already_linked_error);
                 } else {
                     $account_exist_error = isset($message['account_exist_error']) ? $message['account_exist_error'] : '';
                     return edd_set_error('edd_slg_account_already_exist', $account_exist_error);
                 }
             }
             // If the social profile is not linked to any user accounts,
             // use the currently logged in user as the customer
             if (!$user) {
                 $user = get_user_by('id', get_current_user_id());
             }
         }
         if (!$user) {
             // If no user was found, create one
             $user_id = $this->edd_slg_add_user($data);
             $user = get_user_by('id', $user_id);
             // indicate that a new user was created
             $new_customer = true;
         }
         // Update customer's WP user profile and billing details
         $this->edd_slg_update_customer_profile($user->ID, $data, $new_customer);
         if (!is_user_logged_in()) {
             // Log user in or add account linked notice for a logged in user
             wp_set_auth_cookie($user->ID);
             //update last login with social account
             edd_slg_update_social_last_login_timestamp($user->ID, $type);
             do_action('edd_slg_login_user_authenticated', $user->ID, $type);
         } else {
             $_SESSION['edd_slg_linked_notice'] = sprintf(__('Your %s account is now linked to your account.', 'eddslg'), $type);
         }
     }
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:69,代码来源:class-edd-slg-public.php

示例15: edd_process_profile_editor_updates

/**
 * Process Profile Updater Form
 *
 * Processes the profile updater form by updating the necessary fields
 *
 * @since 1.4
 * @author Sunny Ratilal
 * @param array $data Data sent from the profile editor
 * @return void
 */
function edd_process_profile_editor_updates($data)
{
    // Profile field change request
    if (empty($_POST['edd_profile_editor_submit']) && !is_user_logged_in()) {
        return false;
    }
    // Pending users can't edit their profile
    if (edd_user_pending_verification()) {
        return false;
    }
    // Nonce security
    if (!wp_verify_nonce($data['edd_profile_editor_nonce'], 'edd-profile-editor-nonce')) {
        return false;
    }
    $user_id = get_current_user_id();
    $old_user_data = get_userdata($user_id);
    $display_name = isset($data['edd_display_name']) ? sanitize_text_field($data['edd_display_name']) : $old_user_data->display_name;
    $first_name = isset($data['edd_first_name']) ? sanitize_text_field($data['edd_first_name']) : $old_user_data->first_name;
    $last_name = isset($data['edd_last_name']) ? sanitize_text_field($data['edd_last_name']) : $old_user_data->last_name;
    $email = isset($data['edd_email']) ? sanitize_email($data['edd_email']) : $old_user_data->user_email;
    $line1 = isset($data['edd_address_line1']) ? sanitize_text_field($data['edd_address_line1']) : '';
    $line2 = isset($data['edd_address_line2']) ? sanitize_text_field($data['edd_address_line2']) : '';
    $city = isset($data['edd_address_city']) ? sanitize_text_field($data['edd_address_city']) : '';
    $state = isset($data['edd_address_state']) ? sanitize_text_field($data['edd_address_state']) : '';
    $zip = isset($data['edd_address_zip']) ? sanitize_text_field($data['edd_address_zip']) : '';
    $country = isset($data['edd_address_country']) ? sanitize_text_field($data['edd_address_country']) : '';
    $userdata = array('ID' => $user_id, 'first_name' => $first_name, 'last_name' => $last_name, 'display_name' => $display_name, 'user_email' => $email);
    $address = array('line1' => $line1, 'line2' => $line2, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country);
    do_action('edd_pre_update_user_profile', $user_id, $userdata);
    // New password
    if (!empty($data['edd_new_user_pass1'])) {
        if ($data['edd_new_user_pass1'] !== $data['edd_new_user_pass2']) {
            edd_set_error('password_mismatch', __('The passwords you entered do not match. Please try again.', 'easy-digital-downloads'));
        } else {
            $userdata['user_pass'] = $data['edd_new_user_pass1'];
        }
    }
    // Make sure the new email doesn't belong to another user
    if ($email != $old_user_data->user_email) {
        // Make sure the new email is valid
        if (!is_email($email)) {
            edd_set_error('email_invalid', __('The email you entered is invalid. Please enter a valid email.', 'easy-digital-downloads'));
        }
        // Make sure the new email doesn't belong to another user
        if (email_exists($email)) {
            edd_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'easy-digital-downloads'));
        }
    }
    // Check for errors
    $errors = edd_get_errors();
    if ($errors) {
        // Send back to the profile editor if there are errors
        wp_redirect($data['edd_redirect']);
        edd_die();
    }
    // Update the user
    $meta = update_user_meta($user_id, '_edd_user_address', $address);
    $updated = wp_update_user($userdata);
    if ($updated) {
        do_action('edd_user_profile_updated', $user_id, $userdata);
        wp_redirect(add_query_arg('updated', 'true', $data['edd_redirect']));
        edd_die();
    }
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:74,代码来源:shortcodes.php


注:本文中的edd_set_error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。