• Cacique

    (@carlosjavier10)


    The code I show here works when placed in the function.php file of the theme, but in your plugin “code snnipet” it doesn’t let me activate it, it tells me that there is an error in line 2 always (even if I put everything in a single line).

    function my_hidden_filters ($filters)
    {
    if (!empty ($_GET[‘country’]))
    $filters[‘field_24’] = $_GET[‘country’];
    return $filters;
    }

    add_filter (‘bps_hidden_filters’, ‘my_hidden_filters’);

    the development is done locally, and I’m using buddypress with the theme “Twenty Twenty-One”.

    Thank you very much in advance, I hope you can tell me what is going on or if I’m doing something wrong! happy day

    Translated with http://www.DeepL.com/Translator (free version)

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Can you share the error message? I can’t really say for sure what’s going wrong without knowing what it says.

    Here’s a new version of the snippet that should at least fix some common mistakes:

    add_filter( 'bps_hidden_filters', function ( $filters ) {
    	if ( ! empty ( $_GET[ 'country' ] ) ) {
    		$filters[ 'field_24' ] = $_GET[ 'country' ];
    	}
    
    	return $filters;
    } );

    Let me know if it still continues to produce an error.

Viewing 1 replies (of 1 total)

The topic ‘Can’t activate code’ is closed to new replies.