Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress and S2 member Activity problem

  • Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Hello,

    I got one question, I integrated S2 member plugin with buddypress, but I got one problem. I have different types of membership levels (example: level 1, level 2, level 3), when I make post from admin account or another account that I created (editor) every membership level see that post in activity, even level subscribers which are not paid level. If I hide Activity page in general, then they can go on author’s profile and see activity there. If I disable Activity component then it is disabled everywhere even in private groups for that level 1, 2, 3 members.

    So is there way to not show activity from certain account from which I am making posts that only one level should see.

    If I make post for level 2 members for example, then membership levels 2 and 3 should see it.

    If I make post for members on level 3, then only members of level 3 should see it on activity stream.

    If I make post for members on level 1, then members from level 2 and 3 need to see it also.

    Does anyone know how that make that without disabling activity stream component. It would be the best just not to show posts on activity stream from that account that I am making posts, if it is possible to make that.

    Making a url restriction in s2 members doesn’t make sense.

    Thank You and Best regards

Viewing 15 replies - 1 through 15 (of 15 total)
  • Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    You need to apply a filter to the activity sql.

    You can contact me via PhiloPress

    Or post at Jobs

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Hi, is that hard to make? Can I do that by myself maybe?

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    >is that hard to make?

    Not if you understand S2, mysql and pre-query BP filters

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    I think I can do it with custom post type, but now I have problem that posts from custom post type are not showing in category.

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    I tried to add this code to bp-custom.php but it seems that doesn’t work, does anyone maybe have new code?
    Code is used to exclude one user activity from buddypress activity stream.

    <?php
    add_action(“plugins_loaded”,”bpdev_init_sm_mode”);
    function bpdev_init_sm_mode(){
    global $current_user;
    if(is_user_logged_in()) {
    get_currentuserinfo();
    if(“username” == $current_user->user_login) {
    remove_action(“wp_head”,”bp_core_record_activity”);//id SM is on, remove the record activity hook
    }
    }
    }
    ?>

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Not sure, but I believe you need to add get_currentuserinfo(); for the part getting user info.

    Try something like this to debug and see if you get any reponse at all.

    function debug_userinfo() {
    	global $current_user;
          	get_currentuserinfo();
    	echo 'Username: ' . $current_user->user_login . "\n";
          	echo 'User email: ' . $current_user->user_email . "\n";
          	echo 'User first name: ' . $current_user->user_firstname . "\n";
          	echo 'User last name: ' . $current_user->user_lastname . "\n";
          	echo 'User display name: ' . $current_user->display_name . "\n";
          	echo 'User ID: ' . $current_user->ID . "\n";
    }

    See wp codex http://codex.wordpress.org/Function_Reference/get_currentuserinfo

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Hey, can you please tell where I should place that code you posted?

    I am trying to exclude one username from activity stream since with that account I will make posts that are based on different membership levels. Or as I wrote on beginning just exclude all blog posts from activity stream.

    I tried to do it with custom post types, it doesn’t show up in activity stream, which is good, but posts are not showing in category they supposed to show. I read that it is also necessary to post some code somewhere for custom post type.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    To see the output of that, you can either put that in your theme/functions.php or i would say bp-custom.php in dir /plugins/pb-custom.php i saw that simular code of yours on stackoverflow.

    Not sure what you are tying to accomplish with that s2, but the issue is probably not that piece of code, but more trying to get the right levels.

    That code all it does, is checking usernames, so if username is “fred” it will remove the bp_core_record_activity but not according to levels. You need to figure out a way getting it to print out the levels. and then do a if or else statement per level.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    See this link http://www.s2member.com/kb/s2member-conditionals/ it explains how to get the conditionals using PHP, since I do not have s2 installed can’t get them for you

    Did some more reading for ya.

    try if (current_user_is("s2member_level1")) { echo "Woohaa got LEVEL 1" ; }

    and or echo S2MEMBER_CURRENT_USER_ACCESS_LEVEL;

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Ok thank You I will try and let you know.

    What I am trying to accomplish is this. I created couple of categories by membership levels (1,2,3). I restricted those categories in S2 members options so only user that have certain level of membership can see posts in those category.

    Now problem is, when I create post for example for category level 3, everyone (all levels) can see that post in activity stream, that is what I am trying to remove. Posts don’t need to be in activity stream at all, or just to remove activity stream from account that I am making those posts.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    See answer of @shanebp , or use the shortcodes, as explained http://www.s2member.com/kb/simple-shortcode-conditionals/

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    I tried to put your code and changed user login but its not working.

    echo 'Username: ' . $current_user->user_login . "\n";

    echo 'User ID: ' . $current_user->ID . "\n";

    This situation could be done with custom post type, but another problem is that posts are not showing in category that you mark.

    I found on this forum someone had similar problem like mine:

    Posts are added to the activity stream when the post is saved.

    It’s done in the bp_blogs_record_post() function, which is hooked on to the save_post action.

    There isn’t any easy way to filter bp_blogs_record_post() to stop certain categories appearing, so, your best options may be:

    1. To unhook the whole bp_blogs_record_post() function and replace with your own
    or:
    2. Use a custom post type for your teaser posts – the built in function will only post to activity stream if the post type is ‘post’

    That questions and solution is from this link:
    http://buddypress.org/support/topic/resolved-filter-posts-with-specific-categorytag-from-activity-stream/

    If I go with solution 1. that was offered “unhook the whole bp_blogs_record_post() function and replace with your own”, where to find bp_blogs_record_post(), and just to delete it or?

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Yes that could work with shortcodes, but You need to put content every time you make post between that shortcode.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    I hate to tell you this, but there is not a easy way to do what you want to do. And as far as the code, that will echo out ID / USERNAME, and will execute the remove_action function. But that is all it does.

    bp_blogs_record_post function can be found there –> /plugins/buddypress/bp-blogs/bp-blogs-functions.php. However I suggest and of course if you afford it, get a pro to do it for you

    Avatar of crashy11
    crashy11
    Participant

    @crashy11

    Ah, what can I do, I hope in new version of buddypress there will be option to turn off activity for certain account.

    It could be done with custom post type, but then again you need to integrate some code, because when you make post with custom post type, posts are not showing in category they supposed to show.

    Custom post types doesn’t show in activity stream and that could solve to problem, but then again…

Viewing 15 replies - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.