Custom Fields
Re-Envisioned
Support MB Views Author taxonomy / select output

  • Creator
    Topic
  • #33185
    vacdk
    Participant

    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

Viewing 10 replies - 1 through 10 (of 11 total)
  • Author
    Replies
  • #33187
    Long Nguyen
    Moderator

    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 %}
    #33196
    vacdk
    Participant

    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.

    #33209
    Long Nguyen
    Moderator

    Hi,

    Can you please share the PHP code that creates the fields on your site? And some screenshots of the View editor.

    #33211
    vacdk
    Participant

    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.

    #33226
    Long Nguyen
    Moderator

    Hi,

    Can you please share your callback function get_certifikat?

    #33231
    vacdk
    Participant

    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;
    
    }
    #33248
    Long Nguyen
    Moderator

    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?

    #33254
    vacdk
    Participant

    How can I do it without oxygen, I need a template to address the WordPress author page ??

    /author/name

    #33262
    Long Nguyen
    Moderator

    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.

    #33283
    vacdk
    Participant

    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.

Viewing 10 replies - 1 through 10 (of 11 total)
  • You must be logged in to reply to this topic.