0

hi I have this shortcode... [user_meta key="_wc_social_login_profile_image" id=3] It shows the image of a particular user with a special number..

I need to change the number with another shortcode I already have... [user_special_number]

I need the final result to be...

[user_meta key="_wc_social_login_profile_image" id="[user_special_number]"]

4
  • What about using do_shortcode inside your add_shortcode('user_meta') function? developer.wordpress.org/reference/functions/do_shortcode Dec 19, 2017 at 19:41
  • Im not 100% sure how to do it... I have been doing a little with it Dec 19, 2017 at 19:44
  • You can't nest shortcodes in attributes, you should consider forking the shortcode to create a brand new one
    – Tom J Nowell
    Dec 19, 2017 at 20:08
  • Hey Tom, how do I do that? Do you have simple example of doing this? Dec 19, 2017 at 20:12

1 Answer 1

1

You can write something like this

ob_start();
do_shortcode("[user_special_number]");
$special_id = ob_get_clean();

So now you have you your special id, so let's do it again

ob_start();
do_shortcode('[user_meta key="_wc_social_login_profile_image" id="'.$special_id.'"]');
echo ob_get_clean();
2
  • do_shortcode() returns, so output buffering isn't needed at all. In the first block you can just set $special_id to do_shortcode() directly, and in the 2nd block, you can just echo do_shortcode() directly. Dec 20, 2017 at 0:00
  • Hi something a little wrong with this... Im trying to get the social image of any wordpress user and display on a page... Https://graph.facebook.net/sdfsdfsdf .... The code you give doesnt show the url... The user meta shows an image url Dec 20, 2017 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.