Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_get_displayed_user_nav() and apply_filters_ref_array()


  • ChiefAlchemist
    Participant

    @chiefalchemist

    Quick – and quite possibly stupid – question.

    In bp_get_displayed_user_nav() is an apply_filters_ref_array().

    So shouldn’t my filter be receiving an array?

    Yet unless I’ve lost my mind – again? – best I can tell I’m getting a string. I was expecting array(‘<l1>…‘, array of args) but only seem to be getting the ‘<l1>…‘ bit.

    Specifically I want to change the value of $user_nav_item[‘name’] as defined by a plugin I’m using. Is there a way to pre-filter these before the ‘<l1>…‘ is setup?

    Thanks again
    mfs

Viewing 6 replies - 1 through 6 (of 6 total)

  • shanebp
    Moderator

    @shanebp

    >Is there a way to pre-filter these before the ‘<l1>…‘ is setup?

    afaik, no.

    The filter hook is in a foreach loop.
    So you for each item you get an array that has 2 elements- the li code as a string and $user_nav_item.

    So your function could do a string replace on the li item and then echo the result.
    Or use $user_nav_item, except for ‘name’ and create your own li item and then echo the result.


    ChiefAlchemist
    Participant

    @chiefalchemist

    Thanks @shanebp

    What about:

    “…apply_filters_ref_array().

    So shouldn’t my filter be receiving an array?”

    If you can flesh that out really quick I’d appreciate it.


    shanebp
    Moderator

    @shanebp

    It does receive an array.
    “…for each item you get an array that has 2 elements- the li code as a string and $user_nav_item.”


    ChiefAlchemist
    Participant

    @chiefalchemist

    Well. Interesting. Cause that doesn’t seem to be what’s happening for me. I’m able to each the $arg being passed in and it’s spitting out a string, not array*().

    I’ll have another look but I went round and round on this a couple days ago and kept thinking “where the heck is the array? why am I getting a string?

    Weird, right?

    Thanks again @shanebp. As they say, “I’ll be back.”


    shanebp
    Moderator

    @shanebp

    Maybe I’m wrong.
    The best way to tell what you’re getting is to var_dump in your filter function.


    ChiefAlchemist
    Participant

    @chiefalchemist

    @shanepb. Yeah, I’ve done that. But let me have another look.

    You know how it is. Sometimes you get over-focused and things you thought you tried are actually things you meant to try but ran out of time in that moment 🙂

    In any case, thanks again.

    mfs

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘bp_get_displayed_user_nav() and apply_filters_ref_array()’ is closed to new replies.
Skip to toolbar