New Landing How can we help? Themeforest Theme Support Dante Filtering posts by user meta-data

Viewing 3 posts - 1 through 3 (of 3 total)
  • Posted in: Dante
  • #142865
    DanielMcQ
    Member
    Post count: 7

    I’m really loving Dante, but don’t quite grok the Swift Framework shortcodes enough to know whether I can filter posts by user meta-data via short-codes or whether I need to do something more custom:

    – We’re using the Active Directory Integration (ADI) plugin to pull in Active Directory data and use it to populate meta-data on our users.
    – We’re using the “physicaldeliveryofficename” property from AD to know where a user is based
    – We have each possible location string as a WordPress subcategory beneath a top level “Local” category
    – We want to filter a column of posts on our home page to only show posts from the currently logged in user’s physicaldeliveryofficename.

    Is there a short code that would help do this, and if not any suggestions on how to do something more custom to filter a list of “local” posts according to the user’s location?

    Thanks much for any help.

    #142876
    DanielMcQ
    Member
    Post count: 7

    To answer my own question (and hopefully help somebody else who wants to do something similar):

    I added the following code to the SwiftPageBuilderShortcode_recent_posts class in the dante/swift-framework/page-builder/builder/shortcodes/recent_posts.php file. I added it in the content() method at line 33.

    if ($category==”target-local”){
    $user_id = get_current_user_id();
    $key = “location”;
    $single = true;
    $user_location = get_user_meta($user_id, $key, $single);
    $category_array = array($user_location);
    }else{
    $category_array = explode(“,”, $category_slug);
    }

    So, if I mark a post with a category that has a “target-local” slug and if the user’s “location” metadata matches a location subcategory, those posts will be shown.

    Swift Ideas team please let me know if this isn’t the best approach!

    #142905
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Brilliant! I am glad that you managed to resolve the issue.
    Thanks
    Mohammad

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register