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

    @anindyaray

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


    anindyaray
    Member

    @anindyaray

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


    anindyaray
    Member

    @anindyaray

    Hello ! I need help ?


    Hugo Ashmore
    Participant

    @hnla

    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.


    Roger Coathup
    Participant

    @rogercoathup

    @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

    @anindyaray

    @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 :)


    Hugo Ashmore
    Participant

    @hnla

    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

    @anindyaray

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


    Roger Coathup
    Participant

    @rogercoathup

    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.


    Hugo Ashmore
    Participant

    @hnla

    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

    @anindyaray

    @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


    Hugo Ashmore
    Participant

    @hnla

    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

    @anindyaray

    Thank I’ll try and get back to you


    anindyaray
    Member

    @anindyaray

    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’ );
    `


    Hugo Ashmore
    Participant

    @hnla

    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

    @anindyaray

    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()` ?


    Hugo Ashmore
    Participant

    @hnla

    ! == ‘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

    @anindyaray

    :) Thanks


    Hugo Ashmore
    Participant

    @hnla

    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

    @anindyaray

    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