WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Alkivia Open Community] Alkivia User profile information access control (8 posts)

  1. dhewlette
    Member
    Posted 4 years ago #

    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

  2. Txanny
    Member
    Posted 4 years ago #

    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
    }
    ?>
  3. dhewlette
    Member
    Posted 4 years ago #

    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!

  4. Txanny
    Member
    Posted 4 years ago #

    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.

  5. dhewlette
    Member
    Posted 4 years ago #

    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

  6. dhewlette
    Member
    Posted 4 years ago #

    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.

  7. Txanny
    Member
    Posted 4 years ago #

    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.

  8. latestar
    Member
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags