User Meta shortcodes for Formidable

Two shortcodes to add user meta information in a Formdidable Pro view. Very basic.

Formidable hook – shortcode view user meta

add_shortcode( 'view_meta', 'view_meta_shortcode' );

function view_meta_shortcode( $atts ) {
    $atts = shortcode_atts(
        array(
        'user' => '',
        'meta' => '',
        ), $atts, 'view_meta' );
    $results = get_user_meta ($atts['user'],$atts['meta'], true);
    return $results;
}

Formidable hook – shortcode conditionally view user meta

add_shortcode( 'if_view_meta', 'if_view_meta_shortcode');

function if_view_meta_shortcode( $atts, $content = '' ) {
    $atts = shortcode_atts(
        array(
        'user' => '',
        'meta' => '',
        ), $atts, 'if_view_meta' );
    $results = get_user_meta ($atts['user'],$atts['meta'], true);
    if ( $results ) {
        return $content;
    } else {
        return;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *