Archived topic
How to add shortcode into GP comment field
9 replies · Started by Michal on May 8, 2018
Hello,
I am wondering how can I add a country shortcode from geoip plugin (https://pl.wordpress.org/plugins/geoip-detect/) into GP comment field.
[geoip_detect2 property="country"]
From what I noticed comment field has to be a wysiwyg field (not text as it is by default). Is there any other way to do this? By custom php function or so?
Regards,
Michal
You can use this GP Hook
https://docs.generatepress.com/article/generate_inside_comments/
It includes a link showing you how to use the hook
I don't want to have the same shortcode in each comment on my website man;)
I am unclear as to what you need. How is it decided what shortcode goes in which comment?
Imagine I am the user which want to write a following comment:
Hello,
My name is Alex. I came from [geoip_detect2 property="country"] and would ike to introduce myself further.
Blablabla
Cheers
That's what I want to achieve. The shortcode from above works (show visitor's country) on wysiwyg (posts, pages) but not inside comments.
So if the comments field did accept the shortcode are you expecting users to add that shortcode themselves?
NO, Administrator will do that
Sorry David you are not helpful at all. Tom, where are you?:)
Anyway I found a solution by myself. This addon helped resolve that issue https://wordpress.org/plugins/enable-shortcodes-inside-widgetscomments-and-experts/
Hi Michal you may want to look at an alternative method as opening up the comments field to add html can pose a risk to the site or other users with spam content. You may want to investigate a plugin like this:
Hi Michal, sorry i wasn't of much assistance, somethings are lost in translation. I am glad you have found a working solution.