• Resolved Fabbstar

    (@fabbstar)


    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/

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi @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 FROMwp_usermetaWHERE 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.