Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
AdSense Ad Not Appearing
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2017 - 2:56 pm

not sure what you are doing??  are you editing one of our functions?  that would be a bad idea as you lose on upgrades... use our filters... so something like

add_filter('sph_GroupHeaderMessage', 'my_header');
function my_header($out) {
    global $spThisGroup;
    if ($spThisGroup->group_id == 2) {
        # add adsense to $out here
        $out.= '';
    }
    return $out;
}

should get you want you want...  would put the adsense below the normal group header message...  of course, you could just set $out equal to the adsense code if you want to replace it...

Avatar
Justin Erickson
Milwaukee
Member
sp_UserOfflineSmall Offline
Jan 22, 2017 - 3:31 pm

I tried and still can't get it to work. I only know the basics for coding so try to bare with me. 

I tried using the filter and shows no ad. 

Here is the message section. Could you help me with implementing the code. 

I just want to make sure I have the filter correct for group 2. If I do then I can move on with why its not working. 

function sp_GroupHeaderMessage($args='') {
 global $spThisGroup;
 $defs = array('tagId' => 'spGroupHeaderMessage%ID%',
 'tagClass' => 'spHeaderMessage',
 'echo' => 1,
 'get' => 0,
 );
 $a = wp_parse_args($args, $defs);
 $a = apply_filters('sph_GroupHeaderMessage_args', $a);
 extract($a, EXTR_SKIP);

 # sanitize before use
 $tagId = esc_attr($tagId);
 $tagClass = esc_attr($tagClass);
 $echo = (int) $echo;
 $get = (int) $get;

 $tagId = str_ireplace('%ID%', $spThisGroup->group_id, $tagId);

 if ($get) return $spThisGroup->group_message; 

 $out = (empty($spThisGroup->group_message)) ? '' : "<div id='$tagId' class='$tagClass'>$spThisGroup->group_message</div>
";
 $out = apply_filters('sph_GroupHeaderMessage', $out, $a);

 if ($echo) {
 echo $out;
 } else {
 return $out;
 }

}


Milwaukee Auto Market is a very dynamic community to buy, sell or trade any automotive products.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2017 - 3:46 pm

dont understand what that last code is?  looks like our function, so not sure what it means...

I dont see you using a filter, so not sure what you mean by your filter???  do you just mean how you are checking for group id of 2??

If so, then no, yours is incorrect and its in mine:

if ($spThisGroup->group_id == 2)

where of course, $spThisGroup is a global...

Avatar
Justin Erickson
Milwaukee
Member
sp_UserOfflineSmall Offline
Jan 22, 2017 - 3:57 pm

I got the ad to show with the ad code in the filter - $out equal to. 

Putting the code in the Simple:Press Administration group message section does not work for me.

I only have one small problem now. The white background is gone that came with the normal special message. This is how I get the icons to stand out.

You can see here in the first group the ad shows with no white background. In the second group is an ad through the Simple:Press Administration group message section.

How could I fix this?

No White Background Ad

Milwaukee Auto Market is a very dynamic community to buy, sell or trade any automotive products.

Avatar
Justin Erickson
Milwaukee
Member
sp_UserOfflineSmall Offline
Jan 22, 2017 - 4:10 pm

The code I gave is the original code. I didn't edit it at all. I was showing it to see if there is something in it preventing the ad to show.  

I just put the filter you showed at the end. 

Milwaukee Auto Market is a very dynamic community to buy, sell or trade any automotive products.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2017 - 4:18 pm

sorry, the way you were talking, I thought you understood how standard WP filters work...

take the code I gave you in post #11 and put in your spFunctions.php file of your sp theme... as always, you should have a child theme or a custom theme before editing our themes...

you do not need to make any changes to our code files (ie the group header message)...

Avatar
Justin Erickson
Milwaukee
Member
sp_UserOfflineSmall Offline
Jan 22, 2017 - 5:15 pm

I put the filter in the spFunctions.php. It will only work with the ad code in/with the filter.

I cant get the code to work in the Special group message section for the white background. 

When I had the filter in the group view functions the ad wouldn't show while putting the code through the special group message. 

Now that it is in the functions, when trying the code through the special group message, it doesn't work but shows "(adsbygoogle = window.adsbygoogle || []).push({});"?

Im not to sure what im doing wrong lol. 

Milwaukee Auto Market is a very dynamic community to buy, sell or trade any automotive products.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 22, 2017 - 5:55 pm

it will only work with the ad code in/with the filter

guess I dont know what you mean here as I dont think you are actually using a filter, so dont know what you are doing...

remember, I said you have to put your adsense code in the code fragment

$out.= '';

so put your adsense code between the two single quotes.. of course, if you adsense code has single quotes you will need to escape or change to double quotes...

please paste your $out.= code fragment and we can help further...

Avatar
Justin Erickson
Milwaukee
Member
sp_UserOfflineSmall Offline
Jan 22, 2017 - 6:39 pm

I thought the code in post #11 was the filter, "add_filter('sph_GroupHeaderMessage', 'my_header');"?

Yes the adsense code is in the out.=;

With this the ad displays with no background. 

I can write a message in the special group message section and will display as normal with the background. The ad is then pushed down under the message section on its own.

Hope you understand what i'm saying.  

Milwaukee Auto Market is a very dynamic community to buy, sell or trade any automotive products.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 23, 2017 - 4:08 am

So where are you with this this morning? I see an ad in what I assume you mean by the 'white space' so does that mean all is now well.

If not I have to say I don't follow the above conversation enough to make much sense out of it. There seems much confusion so I will be asking you to start from scratch and tell me exactly what and where you want things

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625