admin管理员组文章数量:1122833
I have a working shortcode, ie like this:
[shortcode_name search="" show="url, color, size"]
In this shortcode if I insert for example an email inside search (search="[email protected]") it displays all entries from that e-mail. If I don't write anything, it displays all entries from all e-mails.
I would like to insert a variable like search="'.$user_email.'" to display all entries of that logged user.
How can I use that variable?
I tried also with a shortcode that generates the e-mail, but how to use a shortcode inside another shortcode?
I tried [shortcode_name search="[user_email_shortcode]" show="url, color, size"]
but of course it doesn't work.
I have a working shortcode, ie like this:
[shortcode_name search="" show="url, color, size"]
In this shortcode if I insert for example an email inside search (search="[email protected]") it displays all entries from that e-mail. If I don't write anything, it displays all entries from all e-mails.
I would like to insert a variable like search="'.$user_email.'" to display all entries of that logged user.
How can I use that variable?
I tried also with a shortcode that generates the e-mail, but how to use a shortcode inside another shortcode?
I tried [shortcode_name search="[user_email_shortcode]" show="url, color, size"]
but of course it doesn't work.
1 Answer
Reset to default 1apparently I found the solution (thanks to amatorpl), if anyone needs it:
function show_history() {
$user = wp_get_current_user();
$user_email = $user->user_email;
$show_history = '[shortcode_name search="'.$user_email.'" show="url, color, size"]';
$history = do_shortcode($show_history);
return $history;
}
add_shortcode('show_history', 'show_history');
Thanks for the try
本文标签: Variable inside shortcode or shortcode inside shortcode
版权声明:本文标题:Variable inside shortcode or shortcode inside shortcode 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736285466a1927465.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
[shortcode_name]
created by you? If not, are you able to create your own shortcodes? (You could just create a[shortcode_name_loggedIn]
that basically returns the other shortcode with the email pre-filled) – kero Commented Feb 5, 2021 at 15:18