What should I pass as a parameter to the function pmpro_getMembershipCategories()?
function pmpro_getMembershipCategories($level_id)
Currently when I pass pmpro_getMembershipCategories($current_user->ID);
I get:
array(1) {
[0]=>
string(2) "14"
}
Is that OK?
Then it outputs
Warning: urlencode() expects parameter 1 to be string, array given in /home/e7066/domains/inwima.pl/public_html/wp-includes/formatting.php on line 3690
And links to all posts in all the categories, not just the member’s.
The whole function is:
<?php
$member_level = pmpro_hasMembershipLevel('$current_user->membership_levels', '$current_user->ID');
echo '<pre>';
var_dump($member_level);
echo '</pre>';
$sanitized_title = pmpro_getMembershipCategories($current_user->ID);
echo '<pre>';
var_dump($sanitized_title);
echo '</pre>';
if ($sanitized_title) {
$args = array('post_type' => 'post', 'category_name' => $sanitized_title);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
wp_reset_postdata();
}
}
?>
My goal:
According to how the plugin works, a member has to unlock his access to categories in order to get to a post. I have in each category one post, because what I really want is to have unlockable posts. (BTW the way how it works now is OK, I don’t need to change that).
However, I need to display on a member profile page all the posts he had unlocked (and links to them, I would like to be able to style them too). This means I need to get inside member’s categories and loop through them.