• hi, can you help me? I want to remove shortcode by user type for example

    I have created 2 filter form and both display on member directory, but i want to dsiplay on condition for example
    add_action( ‘init’, ‘remove_my_shortcode’);
    function remove_my_shortcode() {
    if($user_id == 1){
    remove_shortcode(‘[bps_form id=89587]’);
    }else {
    remove_shortcode(‘[bps_form id=65465]’);
    }
    }

    i want to display only 1 based on condition, and not display them all.. can you help please i tried remove_shortcode but not work…

    thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hi r123ze,

    Try this code instead:

    add_filter ('bps_form_order', 'conditionally_remove_form');
    add_filter ('bps_form_query', 'conditionally_remove_form');
    function conditionally_remove_form ($args)
    {
    	if (enter your condition)
    		$args['post__not_in'] = array (89587);  // remove 89587
    	else
    		$args['post__not_in'] = array (65465);  // remove 65465
    
    	return $args;
    }

    There are two add_filter lines because, with the next BP Profile Search version, the name ‘bps_form_order’ will become ‘bps_form_query’.

    Thread Starter r123ze

    (@r123ze)

    thanks it works, i’m using youzer plugin, do you know if it’s possible to display the filter in member directory but not a above, but with youzer directory filters ?

    Thanks.

    Thread Starter r123ze

    (@r123ze)

    btw i think there is a bug on plugin, i created bp member type and url is like this

    mywebsite.com/membres/type/seller/
    mywebsite.com/membres/type/buyer/

    but when I go to seller directory member and try to use filter to search for seller, it return buyer members in search result.. i think it mix data, maybe because search perform in /members and not /membres/type/seller/ ?? how to fix it?

    Thanks.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi r123ze,

    Unfortunately I’m not familiar with Youzer, but perhaps their team will be able to advise you.

    Could your second question be answered by swapping the labels? See the full explanation in:

    https://dontdream.it/swap-the-labels/

    Thread Starter r123ze

    (@r123ze)

    Ok, but for the second question, I didn’t understand your question, how to filter members and stay on the same page. for example if I search on this page.

    mywebsite.com/membres/type/seller/
    I need to get result on that page, and not redirect me to mywebsite.com/membres and display all members.. mixing buyer and seller profile.. hope you get me if you have any solution please?

    Thanks.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi r123ze,

    You can select the target directory of a search form in its Edit Form page but, if you can’t find your member type directory in the Target Directory drop-down, you’ll have to create it with the [bps_directory] shortcode.

    To do that, create a new page and enter this shortcode in its content area:

    [bps_directory bp_member_type='Student']

    Replace ‘Student’ with the actual member type as needed.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘remove bps form on condition’ is closed to new replies.