Skip to content

How to deal with WP_Error? #2601

Closed Answered by gchtr
kilianso asked this question in Q&A
Jun 27, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

I see a couple of things. I think the following line in author.php might be the first issue:

$context['errors'] = is_wp_error($error);

I don’t see where the $error variable is coming from. Did you only publish a part of the template file, or is that it?

The errors variable in Twig is always false, because $error is always undefined and is_wp_error() returns only true if $error is an instance of WP_Error.

Also, I don’t see where you actually instantiate the UserMeta class. The template file doesn’t automatically have access to the UserMeta class. You would have to instantiate it there. I’m thinking something like this might work:

author.php

<?php

$user_meta = new UserMeta();

$context = T…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by kilianso
Comment options

You must be logged in to vote
1 reply
@gchtr
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants