Skip to:
Content
Pages
Categories
Search
Top
Bottom

What necessary changes should be made to BP themes for BP 1.2.6

Viewing 20 replies - 26 through 45 (of 45 total)
  • @anindyaray

    Member

    @hnla : would you kindly give the complete snippet here , as I’m not comfortable with codes :)

    @anindyaray

    Member

    @hnla : are you there ? Please help me with the code snippet , I am not comfortable with code , Please

    @anindyaray

    Member

    Hello ! I need help ?

    @hnla

    Participant

    Erm have you actually tried to add the above snippet adjustment, it’s really not hugely more difficult than the stage you must have already completed in copying my function to your functions.php file.

    Take what I have shown above and add it to the end of the statements that live inside if ( ) so you’ll have a space then the &&

    There is a certain level of code manipulation that you’ll need to get comfortable with doing so give it a go and if stuck post back showing what you tried.

    @rogercoathup

    Participant

    @anindyaray – to write your own theme for BuddyPress, you will need to have a basic knowledge of PHP. The PHP ‘if’ statement is fairly fundamental.

    Checking the tutorial on the PHP site would be a good start: http://www.php.net/manual/en/index.php – then your questions on here can be BuddyPress specific, rather than PHP, allowing this forum to help you (and others) more effectively

    @anindyaray

    Member

    @hnla: :) Thanks :) … but I had tried … , yet I tried once again … but in vain , I am pasteing the code

    `function cancel_header_padding_for_no_adminbar() {
    if(defined( ‘BP_DISABLE_ADMIN_BAR’ ) || $bp->doing_admin_bar = false && !is_user_logged_in()) ?>

    body {padding-top:0;}
    <?php
    }
    add_action( ‘wp_head’, ‘cancel_header_padding_for_no_adminbar’ );`

    this is what I tried :( , but with no luck

    With this function , with or without the && !is_user_logged_in() thing, padding is gone for everybody(logged in and logged out user both)

    @rogercoathup : Thanks for the suggestion I will try to start learning , Everything has a first time :) , actually I’m very much uncomfortable :)

    @hnla

    Participant

    Nope can’t make it work tried many variances and approaches – sorry can’t really spend longer ion it I would now suggest you take this to the theme authors for support.

    @anindyaray

    Member

    @hnla : Ok! but nothing to say sorry , Your tried to help me a lot , Thanks :)

    @rogercoathup

    Participant

    amongst other things, you are doing an assignment there (=), not a test for equality (==). Bracketing the logical parts that belong together would also make your code easier to read.

    @hnla

    Participant

    There you go that was my bad as I wrote that incorrectly in the original and then completely overlooked it when testing it earlier, time to give up this coding game!

    Good spot Roger

    @anindyaray

    Member

    @hnla , @rogercoathup : One thing I donot understand (surrendering that I am a novice) , the snippet suggest that `if user is logged in then the condition is to padd 0px` , but what is need according. to the scenario is `if a user id logged out the padd 0 px , else padd 25 px`
    isn’t it ?

    `
    function cancel_header_padding_for_no_adminbar() {
    if (is_user_logged_in())
    body {padding-top:25;}

    else(defined( ‘BP_DISABLE_ADMIN_BAR’ ) || $bp->doing_admin_bar = false) ?>

    body {padding-top:0;}
    <?php
    }
    add_action( ‘wp_head’, ‘cancel_header_padding_for_no_adminbar’ );
    `

    could it be like this ? I have not tested as I think it has some syntax error

    @hnla

    Participant

    No you’re over complicating you don’t need to add whatever is already stated i.e padding-top: 25px just remove it if certain conditions are met.

    As Roger pointed out the single ‘=’ needs to become the correct ‘is equal to’ operator ‘==’

    @anindyaray

    Member

    Thank I’ll try and get back to you

    @anindyaray

    Member

    I tried this but it didn’t worked , same thing is happening , Sorry :(
    `
    function cancel_header_padding_for_no_adminbar() {

    if(defined( ‘BP_DISABLE_ADMIN_BAR’ ) || $bp->doing_admin_bar == false && !is_user_logged_in()) ?>

    body {padding-top:0;}
    <?php
    }
    add_action( ‘wp_head’, ‘cancel_header_padding_for_no_adminbar’ );
    `

    @hnla

    Participant

    You had it almost correct earlier a little more testing and playing around and you would have got there.

    add back in the outer ‘if’ parent to check first whether the user is logged in so that is as I have shown before:
    !is_user_logged_in()

    Then follow with the other ‘if’ as done before but make sure you have the ‘==’

    so the conditional query says if the user is not logged in then run second ‘if’ and check to see id the constant BP_DISABLE_ADMIN_BAR has been set OR $bp->doing_admin_bar == false is set if either of these two conditions are met then run the following style tag

    The !is_user_logged_in() should probably be run on the add_action rather than within the function to prevent a pointless function being parsed but that would need testing.

    You shouldn’t need the

    @anindyaray

    Member

    Yes atlast … Thanks a lot @hnla and also @rogercoathup :)

    `
    function cancel_header_padding_for_no_adminbar() {

    if(defined( ‘BP_DISABLE_ADMIN_BAR’ ) || $bp->doing_admin_bar == false) ?>

    body {padding-top:0;}
    <?php
    }
    if (!is_user_logged_in())
    add_action( ‘wp_head’, ‘cancel_header_padding_for_no_adminbar’ );
    `

    but One stupid question :
    what is the difference between `!is_user_logged_in()` and `is_user_logged_in()` ?

    @hnla

    Participant

    ! == ‘Not’

    and isn’t really needed the function is either true or false 1 or 0 on it’s own it answers it’s own question – remove the ‘!’ and test again that it works as expected.

    Cool well done had a feeling it was better to simply not run function if user logged in

    @anindyaray

    Member

    :) Thanks

    @hnla

    Participant

    thinking about it it does need to be ‘!’ not otherwise the add_action will only run when that function returns true and we don’t want it running if true

    @anindyaray

    Member

    yes now I understand a bit
    A lot of thanks to you @hnla :)

Viewing 20 replies - 26 through 45 (of 45 total)
  • The topic ‘What necessary changes should be made to BP themes for BP 1.2.6’ is closed to new replies.
Skip to toolbar