How to display user ccaps

Is there a way to simply display the CCAPS level a user has obtained?

I took a shot with this but it displays nothing:

[s2Get constant=“s2member_access_ccaps” /]

I also tried this

<?php $s2member_access_ccaps = get_user_field('s2member_access_ccaps'); ?>

nothing again

Any advice?

Thanks

With respect I think you need to spend more time practising the fundamentals of PHP coding.

or look here

Nothing teaches better than experience.

1 Like

Your snarkly comment doesn’t answer my question. If you look at what I wrote you would see I’ve already been there…for years… I;m not looking for a long list of condionals based on ccaps, just a list of them assigned to a user

Try reading it again or don’t reply if you cannot figure it out…with respect.

That’s correct, but then you get an array… try:

print_r($s2member_access_ccaps);

So you can give it some formatting to be displayed, for example:

echo '<ul>';
foreach ($s2member_access_ccaps as $ccap) {
  echo '<li>'.$ccap.'</li>';
}
echo '</ul>';

That should get you closer to what you want. Let me know if you have more questions.

:slight_smile:

1 Like

Excellent… Almost there.

It did produce the ccap of videos, but added the array line.

I don’t code PHP, but I did this

<?php
$s2member_access_ccaps = get_user_field('s2member_access_ccaps');
print_r($s2member_access_ccaps);
echo '<ul>';
foreach ($s2member_access_ccaps as $ccap) {
 echo '<li>'.$ccap.'</li>';
}
echo '</ul>';
?>

But the result is this:

Your Special Access: Array ( [0] => videos )
videos

Or if they had two ccaps

Your Special Access: Array ( [0] => books [1] => videos )
videos
books

I just need to get rid of the ARRAY line after the label

How?

(Thank so much)
V

Don’t do the print_r, just the foreach.

What would you like the output to be like? I’ll help you with the PHP for it.

:slight_smile:

1 Like

Perfect! Comes out like this:

  • Special Access Granted:
    1. theboss
    2. gratis

I stick the code in a PHP sniplet then use a shortcode to display it

SCREENSHOT

I just replaced ul with ol.

I’m good… You’re the best.

Cheers
Vin

1 Like

Great job! :smiley: