Support Forum
Hi
I'm using the MB views to get taxonomy or a Select field with multiple from authors
{% for item in author.user_select_certifikat %}
{{ item.label }}
{% endfor %}
But I have found an error or something.
When the MB views are getting output, it works fine, but only if an author have created one or more post!
If the author have not created a post, then I'm getting this error:
Warning: array_merge() [function.array-merge]: Expected parameter 1 to be an array, null given in /wp-content/plugins/mb-views/src/Renderer/User.php on line 15
Can you please fix, so the author does not have to create a post to work 🙂
Regards
Hi,
You can check the field value is not empty before using the loop.
{% if author.user_select_certifikat is not empty %}
{% for item in author.user_select_certifikat %}
{{ item.label }}
{% endfor %}
{% endif %}
Hi
Thanks for your reply,
Its not because the value from the term/select box is missing.
The error will come if the author have yet not created a post in a cpt.
Hi,
Can you please share the PHP code that creates the fields on your site? And some screenshots of the View editor.
Here is a video showing..
https://1drv.ms/v/s!Avet-jVvMtjmhBD80rGvPzYmWNXu?e=uZO71Q
Code in views
{% for item in author.user_select_certifikat %}
{{ item.label }}
{% endfor %}
On page shortcode: [mbv name="certifikater"]
Its displayed on the author page in wordpress.
Hi,
Can you please share your callback function get_certifikat
?
Well, i don't thing the callback is the issue, as its doing the same with manual value and label.
But here is the callback
function get_certifikat( ) {
$data=array();
$certificats = get_terms('certifikat', array('hide_empty' => 0, 'parent' =>0));
foreach($certificats as $certificat) {
$data[$certificat->slug]=$certificat->name;
}
return $data;
}
Hi,
Thanks for providing the full info.
I've tried to reproduce the issue on my site but do not see that issue. Can you please use the shortcode without using Oxygen?
How can I do it without oxygen, I need a template to address the WordPress author page ??
/author/name
Hi,
I'm able to reproduce the issue on the author page. The option Post Author
in the MB Views insert fields tab needs the user to have at least one post to become an author. You can try to use the option Current User
instead of that option.
I've escalated this issue to the development team to fix the error message.
Okay, thank you,
Wierd that content only can be displayed if they have posted a post, cause I add them as an author but they only become one after first post ?
But then I have another issue. I have created some CPT, but if they post in these, the author count is not working.
So MetaBox own CPT does not count as posts.
Hi,
They have to create a post or be assigned to be an author to show the View content. Regarding the author of a CPT is not counted, I also experienced that issue. Thanks for your feedback, I will inform the development team to fix all issues.