Assign a key’s value in an array as the return of a function

I have a plugin on my wordpress site that allows me to create team members. I am putting code into my author.php file of my child theme to display the ‘Our Team’ plugin content on the author archive page. The plugin instructs hard coding the template like so (look at usage examples). I need to use the slug argument to get the author’s ‘Our Team’ information; this is what I’m doing:

In author.php in my child theme:

Read More
    <?php
      do_action( 'woothemes_our_team', array(
        'slug' => the_author_meta('user_nicename'),   // This line is the problem
        'display_author_archive'  => false,
        )
      );
    ?>

You can see how I want to use the returned value of the the_author_meta() function as the value for the slug key in the array. However, this does not return the correct result. Instead I get the slug output to the template and every team member name listed underneath that. Using the_author_meta('user_nicename') outputs the correct info when I take it out of the array. Assigning it to a variable did not work either:

    <?php
      $test = the_author_meta('user_nicename');
      do_action( 'woothemes_our_team', array(
        'slug' => $test,
        'display_author_archive'  => false,
        )
      );
    ?>

Hard coding the slug makes the function work the intended way:

    <?php
      $test = 'cleo-g';
      do_action( 'woothemes_our_team', array(
        'slug' => $test,
        'display_author_archive'  => false,
        )
      );
    ?>

The above will output the correct ‘Our Team’ plugin content to the template. Why is it that when the the_author_meta('user_nicename') function outputs the correct data it will not work inside the array as a key value, or even if I assign it to a variable?

Related posts

Leave a Reply

1 comment