PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

changing the background color of a post

  1. Hi

    Is it possible to change the background color of a post or add a default image to the body of that post?

    what im trying to do is if the member is free there post has the white background, If the member is paid there post has a different look ie background font ecs...

    check out http://nichedeliverysystem.com/post-new-ad/

    Whats the best way to do this via GF?

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  2. This does not have to be done in Gravity Forms. It can be done in your template files with some CSS. How do you keep track of the paid status of the member? However you track that, you need to use that information, maybe add to the body class, then have CSS which changes the background based on the status.

    So, how do you know their paid status?

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  3. Reference for adding to the body class:
    http://codex.wordpress.org/Function_Reference/body_class

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  4. Hi Thanks

    Via wishlist member, and yes i know about the css but cant figure out how and where to tag this so if a 365 day member posts its yellow or 180 member posts its green example.

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  5. lol i was reading again the same page you sent me as you where typing i guess im on the right track !!

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  6. I think that is the correct approach. There is probably something in the usermeta record which indicates paid or unpaid, 365 days or 180 days? If so, your function will read that value and based on the value will add to the body class. Then, in your style.css you will add specific CSS rules to style the page differently for each member-based body class.

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  7. ya thats what iv min messing with ill get it you have an example of what the script will look like in functions.php? then what call it in the header.php?

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  8. There is a small change to header.php sometimes, but normally this is already there:

    <body <?php body_class() ?>>

    That will output all the body classes. Your function should add to the existing body classes. Something like this:

    [php]
    // filter the body class
    add_filter( 'body_class', 'adzoom_wishlist_member_classes' );
    
    // function to add body class based on wishlist member 180 or 365 day
    function adzoom_wishlist_member_classes ($classes) {
            // read the wishlist member information somehow
            $userid = 'how to get userid?';
            $key    = 'what is the wishlist member key';
            $single = true; // probably only want a single piece of information, right?
    
            // get the wishlist member level based on the meta key set above
            $wishlistlevel = get_user_meta( $userid, $key, $single );
    
            // pseudocode to add class based on information stored by wishlist member
            if ($wishlistlevel == '365') {
                    // add 'year-member' to the $classes array
                    $classes[] = 'year-member';
            }
            else if ($wishlistlevel == '180') {
                    // add 'half-year-member' to the $classes array
                    $classes[] = 'half-year-member';
            }
    
            // return the $classes array no matter what
            return $classes;
    }

    Then, in style.css you will have some CSS which looks like this":

    [css]
    body.year-member div#content {
    	background-color: yellow;
    }
    
    body.half-year-member div#content {
    	background-color: green;
    }

    If the content area you want to change the background on is not #content, change those lines to match your theme. You might also have to adjust font colors and other things.

    See if that gets you going.

    (not tested BTW - just roughly how to do it)

    Posted 11 years ago on Tuesday July 10, 2012 | Permalink
  9. man thanks did you just write that ?

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  10. thanks so much Chris

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  11. ill keep this updated when i here back from them

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  12. I did just write it. Did not test it though. Need to work out how the information is stored by Wishlist Member so you can pull it out.

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  13. Ok cool ill get it from them i hope they are definitely not you guys!!!! so ill let you know

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  14. Maybe there is documentation or something? Should not be too hard to figure out the format it's stored in.

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  15. Looking through the plugin files a little bit it seems like the level might be stored in the wp_options table? Let us know what you find out. If it's in the options table vs the usermeta table, the approach to get the level for the user will be different.

    Posted 11 years ago on Wednesday July 11, 2012 | Permalink
  16. Ok cool man you would not believe the response from these people, lol ,,,, so ill do what you say, I was headed there anyway man they must outsource there support tickets lol

    RE: wp_options table i need an idea where thats located did not see in the wp default files,,, Are you referring to a table in c panel the plug in made ?

    Posted 11 years ago on Thursday July 12, 2012 | Permalink
  17. GZA
    Member

    Not that we're looking to change the colour of the post depending on duration, but I am interested to know why and how you're using Wishlist Member.

    We're looking to sell listings for 365 days duration, i.e. not restricting access to read the posts but to create the posts.

    When the 365 is up, the lister can either renew for a further 365 days, otherwise their listing (post) is disabled by being marked as 'pending'.

    Can Wishlist Member do this?

    Posted 11 years ago on Thursday July 12, 2012 | Permalink
  18. The wp_options table is a WordPress table which is created when you install WordPress. That was just a guess as to where they are storing the information. I don't have Wishlist Member installed so I was just browsing.

    We really just need that one piece of information: how and where Wishlist Member stores the membership level. With that, we can get it out, and the code I posted will work. Once we know how to get the membership level, we can test the code.

    Posted 11 years ago on Thursday July 12, 2012 | Permalink
  19. whats your email ill give you the log on to my word press ? would that be ok ?

    Posted 11 years ago on Thursday July 12, 2012 | Permalink
  20. Ya still nada the plug in support got back to me they do not do anything that's not basic
    did you want me to send you the info ?

    Posted 11 years ago on Thursday July 12, 2012 | Permalink
  21. Hay Chris here is i think what your looking for ::?

    http://wishlistproducts.com/api/api2/

    there are 2 doc's and has all the distinguishing info between the member classes..

    3 total membership classes the problem im running into is that the that this plug-in create these for each member level "wpm_access[1296320588]" and "wpm_level[1296320588]"
    so i dont think this is the info your requesting ?

    1)
    free : level_id 1331304156
    2)
    2.0_weekly_unlimited_ads
    3)
    2.0_180_days_unlimited_ads
    4)
    2.0_365_days_unlimited_ads : level_id 1331304053

    Posted 11 years ago on Friday July 13, 2012 | Permalink
  22. here is a bit of code that they say works for a reference to you dose it help?

    // get the current user level from WP more important is global $user.
    $user = wp_get_current_user();
    
    // Get user levels from WishlistMembers
    $levels = WLMAPI::GetUserLevels($user->ID);
    
    //then run the check for the level you want like this:
    if(in_array('silver', $levels)){
      //  PRINT OUT THE silver LEVEL stuff here
    }
    elseif (in_array('gold', $levels)){
       // PRINT OUT THE gold LEVEL stuff here
    }
    Posted 11 years ago on Friday July 13, 2012 | Permalink
  23. ya i think the keys are here but i don't know what you need

    http://wishlistproducts.com/wp-content/uploads/2011/07/wlmapi2doc.pdf

    Posted 11 years ago on Friday July 13, 2012 | Permalink
  24. did you need any other info for now?

    Posted 11 years ago on Friday July 13, 2012 | Permalink
  25. Hay Chris i have bin looking around for the keys for this issue and the only stuff i found was what i sent, If that was not what your looking for ? Is there any other resources I can read up on? Or is there a different way to do this?

    Posted 11 years ago on Saturday July 14, 2012 | Permalink
  26. have had 0 luck with this just posted in the paid WL forum for answers. Have you had time to look at this?

    Posted 11 years ago on Tuesday July 17, 2012 | Permalink
  27. Thanks for bumping this topic Scott. I lost the tab when my browser crashed. I'll take a look at it again for you.

    Posted 11 years ago on Tuesday July 24, 2012 | Permalink
  28. What version of WLM are you running? If you’re running the latest v2.71.1330 or greater than you can just do this:
    function function_name() {
    global $current_user;
    $user_id = $current_user->ID;
    $levels = wlmapi_get_member_levels($user_id);
    $levels = $levels['levels']['level'];
    
    //Then, run your if statement
    if ( in_array(365, $levels)) {
    //Do stuff
    }
    }

    just got this back from wish list finally

    there are 3 lev

    2.0 weekly
    2.0 180
    2.0 365

    Posted 11 years ago on Saturday August 11, 2012 | Permalink
  29. Scott, take a look a this code. http://pastebin.com/N5xsg7sN

    I'm flying blind without the plugin, since it's a paid one, but I think based on your last post, this code might work. The only thing I am not sure about is if there can be more that one membership level for a member? The wishlist function returns an array of membership levels, so I just do 3 separate checks to see if 365, 180 or weekly are in the array of membership levels returned. If any of them are, then that specific class is added to the body class. So, in theory, if the user had all three membership levels, the body class could end up looking like this:

    [html]
    <body class="home page page-id-12345 year-member half-year-member week-member">

    with all three classes present. You'd have to work some magic with your CSS to ensure the right styling wins in that case (if that's even a possibility.)

    Let me know if that works. If you put it online, please post a link to the site or email me at chris@rocketgenius.com - thanks,.

    Posted 11 years ago on Monday August 20, 2012 | Permalink
  30. hay thanks Chris Ill let you know on that and post the final proofed code here of corse working on this now

    http://www.gravityhelp.com/forums/topic/i-form-for-1-region-makes-it-easier-for-searchers-to-find-local-stuff

    just wrote a revised comment after reading all day in your forums

    Posted 11 years ago on Monday August 20, 2012 | Permalink

This topic has been resolved and has been closed to new replies.