I am using a plugin that generates a shortcode to display files from a Dropbox folder. I need to display the shortcode on a specific page, but it will be different for each user.

Therefore I have created a custom field for each user, called 'view_files_shortcode'.

I thought I could then call this user custom field on the page, and it would display whatever was set for each user. However it just displays the actual shortcode.

Currently I am using this:

<?php if ( is_user_logged_in() ) {
$userid = get_current_user_id();
get_userdata( $userid );  
get_field('view_files_shortcode', 'user_'. $userid );}?>
<?php the_field('view_files_shortcode', 'user_'. $userid ); ?>

Can anyone tell me how to make the shortcode execute? Thank you.


1 Answer 1


Using the_field(); will just return the content of that field (guessing it's just text field?).

if (is_user_logged_in()) {
    $userid = get_current_user_id();
    $shortcode = get_field('view_files_shortcode', 'user_' . $userid);
<?php echo do_shortcode($shortcode); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.