Skip to:
Content
Pages
Categories
Search
Top
Bottom

CAN BE DELETED

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

  • shanebp
    Moderator

    @shanebp

    You need to check if the button was clicked.
    Try something like this:

    function jay_check_transfer_click() {
    	
        if ( !bp_is_groups_component() && !bp_is_current_action( 'transfer_offer' ) ) 
    	return false;
    	
         send_transfer_offer();
    	
    }		
    add_action( 'bp_actions', 'jay_check_transfer_click' );

    In all your code, you may want to reference the members component instead of groups.


    jayront
    Participant

    @jayront

    Hi thanks for the reply. I tried that and when i clicked on a profile (without it loading to go to the button) it was already adding 4000+ new entries in my DB with the same group_id and user_id.


    jayront
    Participant

    @jayront

    The function just fires instantly when you go the profile page of a user without pressing any buttons on that page.


    shanebp
    Moderator

    @shanebp

    You’ll need to debug.
    Did you try switching from the groups component to members, as I suggested?

    echo bp_current_action(); shows the current action.

    echo bp_current_component(); shows the current component.

    Remove the call to send_transfer_offer() until you’re sure you’re checking for the correct conditions.


    jayront
    Participant

    @jayront

    Hi, i dont know how to do that i’m new to this sorry. I did try

    component’ => ‘profile’,

    also with the echo

    echo bp_current_component(); said my-clubs

    and echo bp_current_action(); said joingroups when i pressed the button (also had the call on but nothing happened there)

    I’m completely fresh with this i have been reading alot but there are stil some things i need to learn.


    jayront
    Participant

    @jayront

    $defaults = array(
    ‘id’ => ‘transfer_offer’,
    ‘component’ => ‘xprofile’,
    ‘must_be_logged_in’ => true,
    ‘block_self’ => true,
    ‘wrapper_class’ => ‘transfer-button ‘,
    ‘wrapper_id’ => ‘transferbutton-‘,
    ‘link_href’ => I DONT KNOW WHAT TO PUT HERE

    ‘link_text’ => __( ‘Transfer Verzoek’, ‘buddypress’ ),
    ‘link_class’ => ‘profile-button transfer-verzoek’,
    );

    I switched the debug mode and used :

    function jay_check_transfer_click() {
    	 echo bp_current_action(); home <--- results
    	 echo bp_current_item(); // sfc-ajax <--- results
    	 echo bp_current_component(); groups <--- results
    	
    }		
    add_action( 'bp_actions', 'jay_check_transfer_click' );

    Then i tried them all in the function but so far it only worked when i clicked on “Profile” in the X-profile of the user, but this is not what i want. When i clicked the button it didn’t call the function. Hope anyone has the solution to this because its driving me nuts lol

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar