Support » Plugin: User Groups » SQL Database

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes the data is stored in the database in teh wp_terms, wp_terms_relationship and wp_terms_taxonomy tables

    Following function may help

    // Get group name by author id (by DN 20150108)
    function get_groupname_by_author_id($aid) {
    global $wpdb;
    $term_ids = $wpdb->get_results(
    $wpdb->prepare( “
    SELECT wp_term_taxonomy.term_id FROM wp_term_taxonomy
    INNER JOIN wp_term_relationships USING (term_taxonomy_id)
    WHERE wp_term_taxonomy.taxonomy = ‘user-group’
    AND wp_term_relationships.object_id = %d
    “,
    $aid)
    );

    if($term_ids) {
    $termid= $term_ids[0]->term_id;
    // echo ” termid: “. $termid;
    } else {
    $termid=””;
    }
    $term = get_term_by( ‘id’, absint($termid), ‘user-group’ );
    $groupname = $term->name;
    if ($groupname) {
    return $groupname;
    } else {
    $groupname = “”;
    return $groupname;
    }
    }

    wp_get_object_terms(2, 'user-group');

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘SQL Database’ is closed to new replies.