• Resolved dhewlette

    (@dhewlette)


    Hey,

    I’m running a highly customized Alkivia user profile template to display all my users and all of their profile information. I’ve added a lot of extra user info to both their WP user profile and their Alkivia user profile. I’m using a plugin called “Register Plus” to store custom, extra user info in the WP database user_meta table, then displaying that info on my Alkivia user profiles pages. Trouble is, I only want to display some of it for public (non-logged in) users, and save the rest for logged in members. I can’t figure out how to do this. I’ve successfully done something similar with the navigation sidebar by using this statement:

    <?php if ( $user_ID ) : ?>
                    <a href="<?php bloginfo('wpurl') ?>/email-members">Email Members</a>
    <?php endif; ?>

    So only logged in members will see this. However, I can’t figure out how to do the same thing for the following code from my Alkivia profile page template:

    <?php if ( ! empty($user->phone) ) {
     _e('Phone: ', $text_domain); echo $user->phone; ?> <?php } ?>

    In this code I check for the users phone number and only display it if they have one listed in their profile. Otherwise I don’t even display “phone:” But when I mess around with adding <?php if ( $user_ID ) : ?> anywhere in that statement nothing works. I want the alkivia profile to be public, but just to hide certain info from non-logged in members through some sort of if statement just like I did for the site navigation. Does anyone know enough PHP and/or Alkivia to help me out with this?

    Thanks,
    Daniel

Viewing 7 replies - 1 through 7 (of 7 total)
  • I would use the wp function is_user_logged_in() to check if the user is logged in or not. I prefer using that function instead checking for $user_id. Anyway, if you want to check for $user_id, first you have to declare it as global.

    <?php
    if ( is_user_logged_in() && ! empty($user->phone) ) {
        _e('Phone: ', $text_domain); echo $user->phone; ?> <?php
    }
    ?>

    this one is my preferred method, but you can also do it that way:

    <?php
    global $user_id;
    if ( $user_id && ! empty($user->phone) ) {
        _e('Phone: ', $text_domain); echo $user->phone; ?> <?php
    }
    ?>
    Thread Starter dhewlette

    (@dhewlette)

    That works perfectly! Thanks!

    What exactly is the difference between the two methods of checking whether a user is logged in or not? Why do you prefer the is)user)logged)in() function over $user_id?

    Also, I want to add some sort of search or organization structure to my Alkivia profile page…is that possible? I’ve got about 200 members for this community page, and was hoping there was a way to add a search box, some method to sort the members by first (or last) name, or something like that. Is there a way to add this somehow?

    Thanks!

    I prefer the function because I have not to declare any global. Using functions also prevents the plugins stop working if the variable name changes in some WP version or if converted to a class in the future. I don’t like accessing globals directly, I think is better to do it with a function.

    Some sort of user search is planned in the future. Sorting the lists is up to you by creating a custom list template.

    Thread Starter dhewlette

    (@dhewlette)

    Ok, makes sense now. Thanks for your replies!

    In terms of sorting users via a custom list template, what could I add to the template that Alkivia would understand? Sorry if that is a beginner question, but I’m not sure how I could add a search box and/or a clickable alphabet to sort via display name (or last name). I can edit the templates just fine, but I have no clue what variables I should be playing with here.

    Thanks

    Thread Starter dhewlette

    (@dhewlette)

    Anyone know about changing the number pagination to an alphabet based one? I’d really like the ability to either search through members using a search box or via some sort of alphabet instead of numbered pages that could appear arbitray to a site visitor.

    Thanks.

    By now there is no way to do it. I will think about including this on a next release as I find it a nice idea.

    Hello, someone is currently designing my website, and I will have three possible conflicts with this plugin: Suffusion Theme, BBpress Integration and Alkivia itself.

    I am not sure these all will mix together. But I want my website to be a place for discussion and social networking. Is Alkivia the best plug in for this?

    latestar

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Alkivia Open Community] Alkivia User profile information access control’ is closed to new replies.