Why when I instantiate wp_error in a validation method my user registration method stops working?

It seems you need to use $errors = new \WP_Error(); in your code, since WP_Error isn’t part of your namespace. I ran a quick test on my machine, using wp-cli commands: Using new WP_Error(): % wp eval ‘namespace PJ\NS\Test; $x = new WP_Error(); var_dump( $x );’ Fatal error: Uncaught Error: Class ‘PJ\NS\Test\WP_Error’ not found in … Read more

Object of class WP_Error could not be converted to string

get_term can return a WP_Error object in addition to a falsy value for term not found or an actual term row. You fix this, by adding an additional check: if (!$term) { continue; } Becomes: if (!$term || is_wp_error($term)) { continue; } You should also do this above the get_term_link call. $term = get_term($value, $fieldSettings[‘taxonomy’]); … Read more

Handling nonce generation in AJAX registration process

If anybody is strangling with it, the proper solution is to use both wp_set_auth_cookie specifying the second parameter being the logged_in cookie, which now gives me the following code: wp_set_current_user($user_id); if ( wp_validate_auth_cookie( ”, ‘logged_in’ ) != $user_id ) { wp_set_auth_cookie( $user_id ); } And to add an action, as suggested in this thread: Extend … Read more

How to display error messages using WP_Error class?

With that in functions.php you’d probably have to declare $error to be global like so : if (‘POST’ == $_SERVER[‘REQUEST_METHOD’] && !empty($_POST[‘action’]) && $_POST[‘action’] == ‘registration’) { global $error; $error = new WP_Error(); // the rest of your code And then do global $error; again on your registration page before trying to use it. But … Read more

Error timed out with succesfull wp_remote_post

After quite some time letting the error message bugging my screen, I figured out a way to solve this. Yes, it’s a timeout issue, and the codex didn’t help me much. So I tried another approach, by setting a filter; add_filter( ‘http_request_timeout’, ‘wp9838c_timeout_extend’ ); function wp9838c_timeout_extend( $time ) { // Default timeout is 5 return … Read more

get_term_children for immediate children only (not grandchildren)

Use the get_terms() function instead: $term_children = get_terms( ‘mytaxname’, array( ‘parent’ => get_queried_object_id(), ) ); if ( ! is_wp_error( $terms ) ) { foreach ( $term_children as $child ) { echo ‘ <div class=”product-archive”> <div class=”post-title”> <h3 class=”product-name”><a href=”‘ . get_term_link( $child ) . ‘”>’ . $child->name . ‘</a></h3> </div> </div> ‘; } } get_terms() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)