Display content when changing a user profile custom field using ACF

28 Views Asked by At

I have created a ACF field group which displays inside a Wordpress user profile. Within that field group is a simple dropdown field with 4 options. I am trying to create a shortcode where by an admin can select one of these options inside a users profile. Once they do this, a button/link/text would appear on a specific page that only the user would see once logged in.

Eg. If an admin selects the 'Approved' option, then the user would see some text on the front end saying 'You're approved'. Here is what I have but it doesn't seem to be working.

add_shortcode('pdf-capa-button', 'capa_btn');

function capa_btn() {   
    
   $user_id = get_current_user_id();
   $variable = get_field('capa_statut', "user_{$id}");      
   $content = '';
    
   if($variable == "CAPA Approved") {
      $content .=  '<p>You are approved!</p>';  
   }
   return $content;
}

Is there anything I'm doing wrong? The code doesn't seem to be throwing any errors but nonetheless, the shortcode isn't generating any content on the front end. Any help would be appreciated

0

There are 0 best solutions below