I am trying to create a ACF field that should be hidden to all users except users in the "Bestyrelse" group. I am using [WordPress groups plugin][1].
The part with hide field based on checked or unchecked is working fine. I am however not really sure about my if-statement that it should show if user is in the "Bestyrelse group":
if( !in_array( "bestyrelsevalg", $row['bestyrelse'] ) && $group = Groups_Group::read_by_name( 'Bestyrelse' ))
See code examples for WordPress Groups plugin: http://docs.itthinx.com/document/groups/api/examples/
My full code:
function investor_bestyrelse_shortcode() {
$rows = get_field('budgetter_og_nyhedsbreve');
if( $rows ) {
$content = '<ul class="dokumenter" style="list-style-type:none;">';
foreach( $rows as $row ) {
if( !in_array( "bestyrelsevalg", $row['bestyrelse'] ) && $group = Groups_Group::read_by_name( 'Bestyrelse' )) {
$pdf = $row['upload_dokument'];
$content = $content . '<li>' . $pdf['title'] . '</li>';
}
}
}
$content = $content . '</ul>';
return $content;
}
add_shortcode( 'investor_bestyrelse', 'investor_bestyrelse_shortcode' );
[1]: http://docs.itthinx.com/document/groups/api/examples/
Aucun commentaire:
Enregistrer un commentaire