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


PHP WP_Error::add方法代码示例

本文整理汇总了PHP中WP_Error::add方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::add方法的具体用法?PHP WP_Error::add怎么用?PHP WP_Error::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Error的用法示例。


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

示例1: wp_authenticate_username_password

function wp_authenticate_username_password($user, $username, $password)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    if (empty($username) || empty($password)) {
        $error = new WP_Error();
        if (empty($username)) {
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
        }
        if (empty($password)) {
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
        }
        return $error;
    }
    $userdata = get_userdatabylogin($username);
    if (!$userdata) {
        return new WP_Error('invalid_username', sprintf(__('<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')));
    }
    $userdata = apply_filters('wp_authenticate_user', $userdata, $password);
    if (is_wp_error($userdata)) {
        return $userdata;
    }
    if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return new WP_Error('incorrect_password', sprintf(__('<strong>ERROR</strong>: Incorrect password. <a href="%s" title="Password Lost and Found">Lost your password</a>?'), site_url('wp-login.php?action=lostpassword', 'login')));
    }
    $user = new WP_User($userdata->ID);
    return $user;
}
开发者ID:jao,项目名称:jpcamargo,代码行数:29,代码来源:user.php

示例2: registrar_usuario

function registrar_usuario($parametros)
{
    $errors = new WP_Error();
    if ($parametros['email'] == NULL) {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
        return $errors;
    }
    if (!es_email($parametros['email'])) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        return $errors;
    }
    if (email_exists($parametros['email'])) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
        return $errors;
    }
    if ($parametros['nombre'] == NULL) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
        return $errors;
    }
    $user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
    $user_id = wp_create_user($parametros['email'], $user_pass, $parametros['email']);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    update_user_option($user_id, 'default_password_nag', true, true);
    //Set up the Password change nag.
    wp_new_user_notification($user_id, $user_pass);
    // Actualización de tabla clientes...
    return $user_id;
}
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:31,代码来源:acciones.php

示例3: unserialize

 function __toString()
 {
     // if the playlist are saved to db, i load it from db
     $playlist = $this->wpdb->get_row("SELECT ID, url, playlist FROM " . $this->table_name . " WHERE url = '" . $this->url . "'");
     if ($this->wpdb->num_rows > 0) {
         $playlist = unserialize($playlist->playlist);
     } else {
         $playlist = array();
         $code = implode("", file($this->url));
         if ($code == "") {
             $this->errors->add('no_content', __('The url $url are not valid!'));
         }
         preg_match_all("/section-row-track(.+)/", $code, $results);
         for ($i = 0; $i < sizeof($results[0]); $i++) {
             preg_match("/class=\"tracklisttrackname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
             $title = $match[1];
             preg_match("/class=\"tracklistartistname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match);
             $artist = $match[1];
             if ($title != "" || $artist != "") {
                 $playlist[] = array("title" => $title, "artist" => $artist);
             }
         }
         $this->wpdb->show_errors();
         // save to db the playlist for this url
         $this->wpdb->insert($this->table_name, array("url" => $this->url, "playlist" => serialize($playlist)), array("%s", "%s"));
     }
     $code = "<h3>Playlist</h3><ul class='mixcloud-embed-playlist'>";
     for ($i = 0; $i < count($playlist); $i++) {
         $code .= "<li><span class='mixcloud-embed-position'>" . ($i + 1) . "</span>";
         $code .= "<span class='mixcloud-embed-artist'>" . $playlist[$i]["artist"] . "</span>";
         $code .= "<span class='mixcloud-embed-title'>" . $playlist[$i]["title"] . "</span></li>";
     }
     $code .= "</ul>";
     return $code;
 }
开发者ID:seoduda,项目名称:Patua,代码行数:35,代码来源:mixcloud-embed-core.php

示例4: eFrontWPI_authenticate

function eFrontWPI_authenticate($user, $user_login, $password)
{
    //Do our basic error checking
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    if (empty($user_login) || empty($password)) {
        $error = new WP_Error();
        if (empty($user_login)) {
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
        }
        if (empty($password)) {
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
        }
        return $error;
    }
    //Attempt Login
    $user = get_user_by('login', $user_login);
    if (!$user || strtolower($user->user_login) != strtolower($user_login)) {
        do_action('wp_login_failed', $user_login);
        return new WP_Error('invalid_username', __('<strong>eFrontWPI</strong>: Login failed, invalid username.'));
    } else {
        eFrontWPI_DoLogin($user, $user_login, $password);
    }
}
开发者ID:ntwrkguru,项目名称:eFrontWPI,代码行数:25,代码来源:eFrontWPI.php

示例5: validate

 function validate()
 {
     if (!isset($_POST['dokan_update_profile'])) {
         return false;
     }
     if (!wp_verify_nonce($_POST['_wpnonce'], 'dokan_settings_nonce')) {
         wp_die(__('Are you cheating?', 'dokan'));
     }
     $error = new WP_Error();
     $dokan_name = sanitize_text_field($_POST['dokan_store_name']);
     if (empty($dokan_name)) {
         $error->add('dokan_name', __('Dokan name required', 'dokan'));
     }
     if (isset($_POST['setting_category'])) {
         if (!is_array($_POST['setting_category']) || !count($_POST['setting_category'])) {
             $error->add('dokan_type', __('Dokan type required', 'dokan'));
         }
     }
     if (!empty($_POST['setting_paypal_email'])) {
         $email = filter_var($_POST['setting_paypal_email'], FILTER_VALIDATE_EMAIL);
         if (empty($email)) {
             $error->add('dokan_email', __('Invalid email', 'dokan'));
         }
     }
     if ($error->get_error_codes()) {
         return $error;
     }
     return true;
 }
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:29,代码来源:template-settings.php

示例6: stripslashes

 function WPPHPBBU_SettingsPage()
 {
     do_action('wpphpbbu_before_admin_settings');
     if (isset($_POST['action']) && $_POST['action'] == 'update') {
         $e = new WP_Error();
         if (!wp_verify_nonce($_POST['_wpnonce'], 'wpphpbbu_settings_page')) {
             $e->add('access_denied', __('You submition does not meet the WordPress security level.', 'wpphpbbu'));
         } else {
             $wpphpbbu_path = stripslashes($_POST['wpphpbbu_path']);
             $wpphpbbu_url = stripslashes($_POST['wpphpbbu_url']);
             $wpphpbbu_post_posts = isset($_POST['wpphpbbu_post_posts']) ? 'yes' : 'no';
             $wpphpbbu_post_locked = isset($_POST['wpphpbbu_post_locked']) ? 'yes' : 'no';
             update_option('wpphpbbu_path', $wpphpbbu_path);
             $is_path = wpphpbbu\Path::is_path_ok();
             if (!$is_path) {
                 $e->add('file_not_exists', __('The file config.php does not exists in the path you have enter', 'wpphpbbu'));
             }
             update_option('wpphpbbu_path_ok', $is_path);
             update_option('wpphpbbu_url', $wpphpbbu_url);
             do_action('wpphpbbu_changed');
             update_option('wpphpbbu_post_posts', $wpphpbbu_post_posts);
             update_option('wpphpbbu_post_locked', $wpphpbbu_post_locked);
         }
     }
     $wpphpbbu_path = trim(get_option('wpphpbbu_path', ABSPATH . 'phpbb3/config.php'));
     $wpphpbbu_url = trim(get_option('wpphpbbu_url', ''));
     $wpphpbbu_post_posts = trim(get_option('wpphpbbu_post_posts', 'yes'));
     $wpphpbbu_post_locked = trim(get_option('wpphpbbu_post_locked', 'yes'));
     require_once __DIR__ . '/admin/settings.php';
     do_action('wpphpbbu_after_admin_settings');
 }
开发者ID:hell4ween,项目名称:wpphpbbunicorn,代码行数:31,代码来源:wpbb_admin.php

示例7: checkPurchaseForm

 public function checkPurchaseForm()
 {
     $errors = new \WP_Error();
     $title = __('Check Purchase Key', 'marketcheck');
     $purchaseKey = $this->getPurchaseKey();
     $selectedMarket = $this->getSelectedMarket();
     $isSubmited = $this->getPostVar('marketcheck-submitted');
     if ($isSubmited) {
         if (!$selectedMarket) {
             $errors->add('invalid-market', __('<strong>Error</strong>: Invalid Market Selected.', 'marketcheck'));
         }
         if (!$purchaseKey) {
             $errors->add('empty_purchase', __('<strong>Error</strong>: Empty Purchase Code.', 'marketcheck'));
         }
     }
     if ($isSubmited && $selectedMarket && $purchaseKey) {
         $this->getCurrentMarket()->setPurchaseKey($purchaseKey);
         $isValidPurchase = $this->getCurrentMarket()->isValidPurchase();
         if (is_wp_error($isValidPurchase)) {
             $errors = $isValidPurchase;
         } else {
             return;
         }
     }
     login_header($title, '<p class="message register">' . $title, $errors);
     $this->showPreRegisterForm();
     login_footer('purchase-key');
     die;
 }
开发者ID:zulfnore,项目名称:MarketCheck,代码行数:29,代码来源:SignUp.php

示例8: wp_authenticate_username_password

function wp_authenticate_username_password($user, $username, $password)
{
    if (is_a($user, 'WP_User')) {
        return $user;
    }
    if (empty($username) || empty($password)) {
        $error = new WP_Error();
        if (empty($username)) {
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
        }
        if (empty($password)) {
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
        }
        return $error;
    }
    $userdata = get_userdatabylogin($username);
    if (!$userdata || $userdata->user_login != $username) {
        return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.'));
    }
    $userdata = apply_filters('wp_authenticate_user', $userdata, $password);
    if (is_wp_error($userdata)) {
        return $userdata;
    }
    if (!wp_check_password($password, $userdata->user_pass, $userdata->ID)) {
        return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.'));
    }
    $user = new WP_User($userdata->ID);
    return $user;
}
开发者ID:schr,项目名称:wordpress,代码行数:29,代码来源:user.php

示例9: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $allow = apply_filters('allow_password_reset', true, $user_data->ID);
    if (!$allow) {
        return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
    } else {
        if (is_wp_error($allow)) {
            return $allow;
        }
    }
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login = %s", $user_login));
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
    $message .= site_url() . '/?ptype=affiliate' . "\r\n";
    $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if ($message && !wp_mail($user_email, $title, $message)) {
        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    }
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:67,代码来源:affiliate_login.php

示例10: rcl_get_login_user

function rcl_get_login_user()
{
    global $wp_errors;
    $pass = sanitize_text_field($_POST['user_pass']);
    $login = sanitize_user($_POST['user_login']);
    $member = isset($_POST['rememberme']) ? intval($_POST['rememberme']) : 0;
    $url = esc_url($_POST['redirect_to']);
    $wp_errors = new WP_Error();
    if (!$pass || !$login) {
        $wp_errors->add('rcl_login_empty', __('Fill in the required fields!', 'wp-recall'));
        return $wp_errors;
    }
    if ($user = get_user_by('login', $login)) {
        $user_data = get_userdata($user->ID);
        $roles = $user_data->roles;
        $role = array_shift($roles);
        if ($role == 'need-confirm') {
            $wp_errors->add('rcl_login_confirm', __('Your email is not confirmed!', 'wp-recall'));
            return $wp_errors;
        }
    }
    $creds = array();
    $creds['user_login'] = $login;
    $creds['user_password'] = $pass;
    $creds['remember'] = $member;
    $user = wp_signon($creds, false);
    if (is_wp_error($user)) {
        $wp_errors = $user;
        return $wp_errors;
    } else {
        rcl_update_timeaction_user();
        wp_redirect(rcl_get_authorize_url($user->ID));
        exit;
    }
}
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:35,代码来源:authorize.php

示例11: widget_retrieve_password

function widget_retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'templatic'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'templatic'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'templatic'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    ////////////////////////////////////
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login like \"{$user_login}\" or user_email like \"{$user_login}\"");
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key', 'templatic'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = '<p><b>' . __('Your login Information :', 'templatic') . '</b></p>';
    $message .= '<p>' . sprintf(__('Username: %s', 'templatic'), $user->user_login) . "</p>";
    $message .= '<p>' . sprintf(__('Password: %s', 'templatic'), $new_pass) . "</p>";
    $message .= '<p>You can login to : <a href="' . get_option('siteurl') . '/' . "\">Login</a> or the URL is :  " . get_option('siteurl') . "/?ptype=login</p>";
    $message .= '<p>Thank You,<br> ' . get_option('blogname') . '</p>';
    $user_email = $user_data->user_email;
    $user_name = $user_data->user_nicename;
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $title = sprintf(__('[%s] Your new password', 'templatic'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '');
    ///forgot password email
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:58,代码来源:login.php

示例12: wp_signon

function wp_signon($credentials = '')
{
    if (empty($credentials)) {
        if (!empty($_POST['log'])) {
            $credentials['user_login'] = $_POST['log'];
        }
        if (!empty($_POST['pwd'])) {
            $credentials['user_password'] = $_POST['pwd'];
        }
        if (!empty($_POST['rememberme'])) {
            $credentials['remember'] = $_POST['rememberme'];
        }
    }
    if (!empty($credentials['user_login'])) {
        $credentials['user_login'] = sanitize_user($credentials['user_login']);
    }
    if (!empty($credentials['user_password'])) {
        $credentials['user_password'] = trim($credentials['user_password']);
    }
    if (!empty($credentials['remember'])) {
        $credentials['remember'] = true;
    } else {
        $credentials['remember'] = false;
    }
    do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password']));
    // If no credential info provided, check cookie.
    if (empty($credentials['user_login']) && empty($credentials['user_password'])) {
        $user = wp_validate_auth_cookie();
        if ($user) {
            return new WP_User($user);
        }
        if (!empty($_COOKIE[AUTH_COOKIE])) {
            return new WP_Error('expired_session', __('Please log in again.'));
        }
        // If the cookie is not set, be silent.
        return new WP_Error();
    }
    if (empty($credentials['user_login']) || empty($credentials['user_password'])) {
        $error = new WP_Error();
        if (empty($credentials['user_login'])) {
            $error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
        }
        if (empty($credentials['user_password'])) {
            $error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
        }
        return $error;
    }
    $user = wp_authenticate($credentials['user_login'], $credentials['user_password']);
    if (is_wp_error($user)) {
        return $user;
    }
    wp_set_auth_cookie($user->ID, $credentials['remember']);
    do_action('wp_login', $credentials['user_login']);
    return $user;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:55,代码来源:user.php

示例13: wpmoly_ajax_filter

/**
 * Pre-handle AJAX Callbacks results to detect errors
 * 
 * Execute the callback and filter the result to prepare the AJAX
 * response. If errors are detected, return a WP_Error instance.
 * If no error, return the callback results.
 * 
 * @param    mixed    $callback Array containing Callback Class and Method or simple string for functions
 * @param    array    $args Array of arguments for callback
 * 
 * @return   array|WP_Error    Array of callback results if no error,
 *                             WP_Error instance if anything went wrong.
 */
function wpmoly_ajax_filter($callback, $args = array(), $loop = false)
{
    $loop = true === $loop ? true : false;
    $response = array();
    $errors = new WP_Error();
    // Simple function callback
    if (!is_array($callback) && function_exists(esc_attr($callback))) {
        // Loop through the arg
        if ($loop && is_array($args) && !empty($args)) {
            foreach ($args[0] as $arg) {
                $_response = call_user_func_array($callback, array($arg));
                if (is_wp_error($_response)) {
                    $errors->add($_response->get_error_code(), $_response->get_error_message());
                } else {
                    $response[] = $_response;
                }
            }
        } else {
            $_response = call_user_func_array($callback, $args);
            if (is_wp_error($_response)) {
                $errors->add($_response->get_error_code(), $_response->get_error_message());
            } else {
                $response[] = $_response;
            }
        }
    } else {
        if (is_array($callback) && 2 == count($callback) && class_exists($callback[0]) && method_exists($callback[0], $callback[1])) {
            // Loop through the arg
            if ($loop && is_array($args) && !empty($args)) {
                foreach ($args[0] as $arg) {
                    $_response = call_user_func_array(array($callback[0], $callback[1]), array($arg));
                    if (is_wp_error($_response)) {
                        $errors->add($_response->get_error_code(), $_response->get_error_message());
                    } else {
                        $response[] = $_response;
                    }
                }
            } else {
                $_response = call_user_func_array(array($callback[0], $callback[1]), $args);
                if (is_wp_error($_response)) {
                    $errors->add($_response->get_error_code(), $_response->get_error_message());
                } else {
                    $response[] = $_response;
                }
            }
        } else {
            $errors->add('callback_error', __('An error occured when trying to perform the request: invalid callback or data.', 'wpmovielibrary'));
        }
    }
    if (!empty($errors->errors)) {
        $response = $errors;
    }
    return $response;
}
开发者ID:masterdoed,项目名称:wpmovielibrary,代码行数:67,代码来源:wpmoly-ajax-functions.php

示例14: xtec_settings_allow_password_reset

/**
 * Deny password reset.
 *
 * @param bool $b
 * @param int $userid The ID of a user.
 * @return WP_Error.
 */
function xtec_settings_allow_password_reset($b, $userid)
{
    $user = get_user_by('id', $userid);
    if (strlen($user->user_login) < 9) {
        $error = new WP_Error('no_password_reset', "<strong>No és possible reinicialitzar la contrasenya.</strong>");
        $error->add('no_password_reset', "Si sou un usuari de la XTEC i heu perdut la vostra contrasenya podeu visitar <a href=\"http://www.xtec.cat/web/at_usuari/at_usuari\">l'enllaç següent</a>.");
        $error->add('no_password_reset', "En cas que no sigueu un usuari de la XTEC i hàgiu perdut la vostra contrasenya, us haureu de posar en contacte amb l'usuari que us va donar d'alta al servei de blocs.");
        return $error;
    } else {
        return true;
    }
}
开发者ID:ignacioabejaro,项目名称:xtecblocs,代码行数:19,代码来源:xtec-settings.php

示例15: px_verify_purchase

/**
* Verify the code using the envato api
**/
function px_verify_purchase($code, $check = true)
{
    $errors = new WP_Error();
    if (empty($code)) {
        $errors->add('incomplete_form', '<strong>Error</strong>: Incomplete form fields.');
        return $errors;
    }
    $options = get_option('px_verifiy_settings');
    $personal_token = $options['px_verifiy_token'];
    if ($personal_token == false) {
        $errors->add('incomplete_settings', '<strong>Error</strong>: Please contact admin to setup the plugin settings.');
        return $errors;
    }
    $api_url = 'https://api.envato.com/v2/market/author/sale?code=' . $code;
    $verified = false;
    // check if purchase code already used
    if ($check) {
        global $wpdb;
        $query = $wpdb->prepare("SELECT umeta.user_id\n\t\t\tFROM {$wpdb->usermeta} as umeta\n\t\t\tWHERE umeta.meta_value LIKE '%%%s%%' ", $code);
        $registered = $wpdb->get_var($query);
        if ($registered) {
            $errors->add('used_purchase_code', 'Sorry, but that item purchase code has already been registered with another account. Please login to that account to continue, or create a new account with another purchase code.');
            return $errors;
        }
    }
    // Send request to envato to verify purchase
    $headers = array('Authorization' => 'Bearer ' . $personal_token);
    $response = wp_remote_get($api_url, array('headers' => $headers));
    $result = '';
    if (isset($response['body'])) {
        $result = json_decode($response['body'], true);
        if (isset($result['error']) && isset($result['response_code'])) {
            $errors->add('invalid_purchase_code', '<strong>Error ' . $result['response_code'] . '</strong>: ' . $result['error']);
            return $errors;
        } else {
            if (isset($result['error']) && isset($result['error_description'])) {
                $errors->add('invalid_purchase_code', '<strong>' . $result['error'] . '</strong>: ' . $result['error_description']);
                return $errors;
            } else {
                if (isset($result['error']) && isset($result['description'])) {
                    $errors->add('invalid_purchase_code', '<strong>' . $result['error'] . '</strong>: ' . $result['description']);
                    return $errors;
                } else {
                    $verify = array('px_envato_username' => $result['buyer'], 'px_envato_purchase_date' => $result['sold_at'], 'px_envato_purchase_code' => $code, 'px_envato_license' => $result['license'], 'px_envato_item' => $result['item']['name'], 'px_envato_support_amount' => $result['support_amount'], 'px_envato_support_until' => $result['supported_until']);
                    return $verify;
                }
            }
        }
    } else {
        $errors->add('invalid_api_response', '<strong>Invalid response from the API</strong>');
        return $errors;
    }
}
开发者ID:pixelartdev,项目名称:Pixelart-Verifier,代码行数:56,代码来源:login.php


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