Title: Using shortcode within HTML Content Field
Last modified: September 1, 2016

---

# Using shortcode within HTML Content Field

 *  Resolved [Fabbstar](https://wordpress.org/support/users/fabbstar/)
 * (@fabbstar)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-within-html-content-field/)
 * Hi there,
 * I want to capture the user type so I can run a custom formula. Unfortunately 
   there isn’t a user type option in the DS fields.
 * I’ve created a shortcode which gets the user type of the logged in user but unfortunately
   it the HTML content field doesn’t convert the shortcode, only displays the [get_user_role]
   shortcode I created.
 * Is there a solution for this?
 * Thanks,
    F
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-within-html-content-field/#post-7569812)
 * Hi [@fabbstar](https://wordpress.org/support/users/fabbstar/),
 * You can get the ID of the logged user, inserting a “Hidden DS” field. Select 
   the “User Data” as the datasource, the “ID” option for the “Attribute for values”,
   and tick the checkbox: “Display data of logged user” (I’ll assume this field 
   is the fieldname1)
 * Now, to get the role of the user, you should insert for example, a “Line Text
   DS” field, select the “Database” option as datasource, and finally, enter as 
   the query associated to the field the following one:
 * `SELECT SUBSTRING(meta_value,LOCATE('"',meta_value)+1,(LOCATE('"',SUBSTRING(meta_value,
   LOCATE('"',meta_value)+1)))-1) as value FROM`wp_usermeta`WHERE user_id=<%fieldname1%
   > AND meta_key='wp_capabilities'`
 * of course, if the database prefix in your WordPress is different, you should 
   replace the table name: wp_usermeta, to use the correct one.
 * Best regards.

Viewing 1 replies (of 1 total)

The topic ‘Using shortcode within HTML Content Field’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

## Tags

 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 1 reply
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/using-shortcode-within-html-content-field/#post-7569812)
 * Status: resolved