Forum Replies Created

Viewing 15 replies - 31 through 45 (of 69 total)
  • Thread Starter Henry

    (@henrywright-1)

    If you hover over my avatar and then look at the bottom left hand corner of the browser window you’ll see what I mean

    Thread Starter Henry

    (@henrywright-1)

    paulwpxp, this is exactly what i was trying to find out. Thanks for your help!

    Thread Starter Henry

    (@henrywright-1)

    Humm, spoke slightly too soon. Although it is working on the profile page, the button isn’t displayed at all in the members loop.

    Thread Starter Henry

    (@henrywright-1)

    OK managed to filter the button properly now.

    function custom_follow_button( $button ) {
    
    global $bp, $members_template;
    
    		$defaults = array(
    			'leader_id'   => bp_displayed_user_id(),
    			'follower_id' => bp_loggedin_user_id()
    		);
    
    		$r = wp_parse_args( $args, $defaults );
    		extract( $r );
    
    		if ( !$leader_id || !$follower_id )
    			return false;
    
    		// if we're checking during a members loop, then follow status is already queried via bp_follow_inject_member_follow_status()
    		if ( !empty( $members_template->member ) && $follower_id == bp_loggedin_user_id() && $follower_id == bp_displayed_user_id() ) {
    			$is_following = $members_template->member->is_following;
    		}
    		// else we manually query the follow status
    		else {
    			$is_following = bp_follow_is_following( array( 'leader_id' => $leader_id, 'follower_id' => $follower_id ) );
    		}
    
    		// if the logged-in user is the leader, use already-queried variables
    		if ( bp_loggedin_user_id() && $leader_id == bp_loggedin_user_id() ) {
    			$leader_domain   = bp_loggedin_user_domain();
    			$leader_fullname = bp_get_loggedin_user_fullname();
    		}
    		// else we do a lookup for the user domain and display name of the leader
    		else {
    			$leader_domain   = bp_core_get_user_domain( $leader_id );
    			$leader_fullname = bp_core_get_user_displayname( $leader_id );
    		}
    
    		// setup some variables
    		if ( $is_following ) {
    			$id        = 'following';
    			$action    = 'stop';
    			$class     = 'unfollow';
    			$link_text = $link_title = sprintf( __( 'Stop Following %s', 'bp-follow' ), apply_filters( 'bp_follow_leader_name', bp_get_user_firstname( $leader_fullname ), $leader_id ) );
    		}
    		else {
    			$id        = 'not-following';
    			$action    = 'start';
    			$class     = 'follow';
    			$link_text = $link_title = sprintf( __( 'Follow %s', 'bp-follow' ), apply_filters( 'bp_follow_leader_name', bp_get_user_firstname( $leader_fullname ), $leader_id ) );
    		}
    
    		// setup the button arguments
    		$button = array(
    			'id'                => $id,
    			'component'         => 'follow',
    			'must_be_logged_in' => true,
    			'block_self'        => empty( $members_template->member ) ? true : false,
    			'wrapper_class'     => 'follow-button ' . $id,
    			'wrapper_id'        => 'follow-button-' . $leader_id,
    			'link_href'         => wp_nonce_url( $leader_domain . $bp->follow->followers->slug . '/' . $action .'/', $action . '_following' ),
    			'link_text'         => $link_text,
    			'link_title'        => '',
    			'link_id'           => $class . '-' . $leader_id,
    			'link_class'        => $class
    		);
    
       return $button;
    }
    add_filter( 'bp_follow_get_add_follow_button', 'custom_follow_button' );

    Link title was the only part I changed as poedit accepts HTML markup so was able to swap out the text for an image using the localisation file.

    The approach works for me but if there is an easier way….? (i’m sure my filter can be stripped down too – probably have unnecessary stuff in there)

    Ref: bp-follow-templatetags.php line 117

    Thread Starter Henry

    (@henrywright-1)

    Hi r-a-y

    I’ve tried to use the filter approach but just can’t seem to get it to work. My PHP is failing me :{

    Any pointers would be really helpful?

    Thread Starter Henry

    (@henrywright-1)

    Hi damienoneill2001,

    Yes, Andrea kindly pointed out my BuddyPress child theme wasn’t set up properly

    https://codex.buddypress.org/legacy/building-a-buddypress-child-theme/

    Also whilst trying to resolve i found the search uses ajax pagination which relies heavily on the page HTML in order to work properly. If you start removing or modifying elements in members-loop.php then you’ll come across problems.

    If your pagination or search is broken after you’ve customised your theme, then i suggest you start with everything as it comes out of the box, gradually add in your customisations, testing to ensure everything works as you go along. Bit of a laborious process but a ‘must-do’ as ajax/javascript is involved.

    Hope this helps

    Thread Starter Henry

    (@henrywright-1)

    Absolutely fantastic support. Many thanks!

    Forum: Fixing WordPress
    In reply to: IE5 problem
    Henry

    (@henrywright-1)

    I had to use I.E. 6 at work up until 2010 but then they updated. You should really urge the IT guys at your office to update IE as i’m sure there will be many security issues with such an old version

    Thread Starter Henry

    (@henrywright-1)

    Thanks Andrea, i’ve sent an email with the access details.

    Thread Starter Henry

    (@henrywright-1)

    Thanks, worked perfectly!

    Thread Starter Henry

    (@henrywright-1)

    Good question. You’d have to ask my user who reported the error. Perhaps they didn’t realise they were logged in?

    Thanks for the suggestion, however, it didn’t resolve the issue.

    Thread Starter Henry

    (@henrywright-1)

    Thanks for the info.

    Thread Starter Henry

    (@henrywright-1)

    I just saw your reply on Trac. Thanks for taking the time to try to resolve the issue. Hopefully one of the BP dev team will be able to respond

    Thread Starter Henry

    (@henrywright-1)

    Thanks for the ideas, think i’ll give the filter approach a shot!

    Thread Starter Henry

    (@henrywright-1)

    Yep, it was thanks to Boone’s explanation that I realised you can’t use bp_displayed_user_id() in that context.

    Thanks for your help (the wiki on Github has been quite helpful)!

Viewing 15 replies - 31 through 45 (of 69 total)