Site logo

Archived topic

Code is not working correctly when inserted into a hook element

3 replies · Started by Carsten on June 12, 2020

Viewing posts 1–4 of 4

Hi there, I have added this code to an element, which is intended to show profiles own gallery. It does show a gallery, but it's the total records outputted to all profiles.

The developer of the Flexi gallery plugin, gives this explanation, to why it is not working:

It will only work on buddypress profile page.
I have not idea about elements where you are inserting.

<?php
 $user_info = bp_get_displayed_user_username();
  echo do_shortcode('[flexi-gallery user="' . $user_info . '" ] ');
?>

I use a BuddyPress custom hook bp_after_profile_content so it is on the profile page.

Any idea, why this code should not work, when inserted into a hook element?

Hi there,

Not sure why it wouldn't work in an Element, but you can try a manual hook:

add_action( 'bp_after_profile_content', function() {
    $user_info = bp_get_displayed_user_username();
    echo do_shortcode('[flexi-gallery user="' . $user_info . '" ] ');
} );

If that doesn't work, you can show it to the developer, as they should know about regular actions/hooks.

Hi there, thanks for your reply, I have tested the manual action hook with same result, so it definitely rules out any issues with the element.

Thanks again for helping out.

No problem :)

This archived topic is closed to new replies.