WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Variable Not Working Inside is_author() Array (2 posts)

  1. chazbeaner
    Member
    Posted 1 year ago #

    I'm using a plugin (User Groups) to separate out users into, well, groups, and I need to figure out a way to create a conditional to check if an author is in a certain group. So, using get_term_by and get_objects_in_term, I was able to build a string of author IDs. See below:

    $taxonomy = 'user-group';
    $taxonomy_group_name = 'author-group';
    $taxonomy_group_id = get_term_by('slug' , $taxonomy_group_name, $taxonomy, 'OBJECT');
    $taxonomy_group_ids = get_objects_in_term($taxonomy_group_id->term_id, $taxonomy);
    $taxonomy_id_list = implode(',', $taxonomy_group_ids);

    So, I can take the list stored in $taxonomy_id_list and echo it out and get a string that looks like the below:

    1,2,3,4,5,6,7

    For the conditional, I should then be able to say:

    if(is_author(array($taxonomy_id_list))) { }

    But that doesn't work. If I paste the raw list into the array, it works as it should, but if I try to use the variable inside the array, the conditional does not work.

    What am I missing? Why wouldn't that variable work?

  2. chazbeaner
    Member
    Posted 1 year ago #

    Figured it out, can use the array defined one step earlier:

    is_author($taxonomy_group_ids)

    http://stackoverflow.com/questions/1125730/how-can-i-split-a-comma-delimited-string-into-an-array-in-php

Topic Closed

This topic has been closed to new replies.

About this Topic