Custom Fields
Support MB User Meta Add an iframe embed code in a user custom field, display via shortcode in post

  • Creator
  • #28661
    Resolved Lucas

    I'm using Client Portal to create portal pages for each user. With User Meta, I added a text field with an iframe embed code.
    I wanted to display that embed on the front end based on the user's login. I used a shortcode in the post content:
    [rwmb_meta id="custom_field_id"]
    However, nothing displays. Any suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
  • #28681
    Long Nguyen

    Hi Lucas,

    The text field has the default sanitization callback sanitize_text_field which does not allow any tags.

    You can bypass this sanitization by using setting

    'sanitize_callback' => 'none'

    Get more details on this documentation


    Thank you!
    I added "none" but the iframe didn't display.
    I have also tried adding a simple url, then writing the iframe into the page with the shortcode embedded:
    However, that embeds the current page nested infinitely.
    I think I'm missing something basic about how to pull a url from a custom field with a shortcode.

    Long Nguyen

    Hi Lucas,

    The field text or textarea content does not support parsing the shortcode in the attribute URL. If you want to do that, please use the PHP code in your template file

    echo '<iframe src='. do_shortcode( '[rwmb_meta id="field_url" object_id=1 object_type="user"]' ) .' width="680" height="480" allowfullscreen></iframe>';

    Or simply add the tag <iframe> in the field WYSIWYG content with attribute URL

    <iframe src="" width="680" height="480" allowfullscreen></iframe>

    then use the shortcode to show the user field value

    [rwmb_meta id="field_url" object_id=1 object_type="user"]

    Get more shortcode details here

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.