dimanche 26 juin 2016

BuddyPress Filter Activity bp-custom.php

My WooCommerce plugin adds you to a private group upon purchase success. If you are a member of that group you have a badge on your profile and by your name in activity updates (that works perfectly fine). I added code to activity/entry.php, activity/comment.php, and members/single/member-header.php to accomplish that.

<?php

$id               = get_current_user_id();
$premium_group_id = 13;

function bp_activity_filter_kses($content)
{
    global $allowedtags;

    $activity_allowedtags = $allowedtags;

    if (groups_is_user_member($id, $premium_group_id)) {

        $activity_allowedtags['a']['href']   = array();
        $activity_allowedtags['b']           = array();
        $activity_allowedtags['i']           = array();
        $activity_allowedtags['darkblue']    = array();
        $activity_allowedtags['darkgreen']   = array();
        $activity_allowedtags['darkaqua']    = array();
        $activity_allowedtags['darkred']     = array();
        $activity_allowedtags['darkpurple']  = array();
        $activity_allowedtags['gold']        = array();
        $activity_allowedtags['gray']        = array();
        $activity_allowedtags['darkgray']    = array();
        $activity_allowedtags['blue']        = array();
        $activity_allowedtags['green']       = array();
        $activity_allowedtags['aqua']        = array();
        $activity_allowedtags['red']         = array();
        $activity_allowedtags['lightpurple'] = array();
        $activity_allowedtags['yellow']      = array();
        $activity_allowedtags['a']['href']   = array();

    } else {
        $activity_allowedtags['a']['href'] = array();
    }

    $activity_allowedtags = apply_filters('bp_activity_allowed_tags', $activity_allowedtags);
    return wp_kses($content, $activity_allowedtags);
}
?>

Anyhow I removed this function from the BuddyPress source code and put it in bp-custom.php. What I'm trying to do is only let premium members use the cool HTML tags. I'm thinking that it's not registering the ID or something because when I echo it it says 0.

Do I need to move this function somewhere else? Is my if statement messed up? Somebody tell me how I can accomplish what I'm trying to do. I use this same code in all the other files I mentioned previously and it works fine so I don't know what troubleshooting step to take next.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire