With the WPMU Membership plugin (I am thinking

With the WPMU Membership plugin (I am thinking of installing it for paywall content), I see that there are various tags for user level in the documentation:

[level-visitors]
[level-level-2]
[level-level-3]
[not-level-visitors]
[not-level-level-2]
[not-level-level-3]

My question is that I need to be able to show Google's crawler the *full* page content, with no paywall redirection (I know this is dangerous as people could spoof their user agent, but, I don't mind) - could I make a tag (like the tags above) for if the user agent is Google's crawler? Or regardless of tags, just detect whether Google's crawler is viewing the page?

Is this possible somehow? Or even with another plugin working alongside WPMU Membership?

So for example, if I had a page on "Secret tips for personal trainers", I'd force humans to sign up before they view it (and if they're not signed up, they see the default "please sign up" message), however if Google comes across the page, I'd like it to be able to see everything.

Do you have any idea of how I can go about achieving this?

Regards

  • Ash

    @Vinod Dalvi: I hope you wouldn't mind me chiming in.

    @propages: I think it's possible. This is a nice idea to show the full content for SE crawler and when visitor comes in your site, ask them to register. Pretty good idea. Well, for that first you need to detect if it is a crawler. You can try the following code in your functions.php.

    add_action('the_content', 'make_open_for_bot');
    function make_open_for_bot($content) {
    	$iscrawler = getIsCrawler($_SERVER['HTTP_USER_AGENT']);
    	if ($isCrawler)
    		$content = preg_replace('/\[[^\]]*]/', '', $content);
    	return $content;
    }
    
    function getIsCrawler($userAgent)
    {
    	$crawlers = 'Google|msnbot|Rambler|Yahoo|AbachoBOT|accoona|' .
    	'AcioRobot|ASPSeek|CocoCrawler|Dumbot|FAST-WebCrawler|' .
    	'GeonaBot|Gigabot|Lycos|MSRBOT|Scooter|AltaVista|IDBot|eStyle|Scrubby';
    	$isCrawler = (preg_match("/$crawlers/", $userAgent) > 0);
    	return $isCrawler;
    }

    Here getIsCrawler function is checking if it is a crawler. If it is, then we will omit the shortcodes that are using in the page. It should work :slight_smile:

    Please let me know if it is helpful and feel free to ask more question if you have.

    Cheers
    Ash

  • Vinod Dalvi

    Hi @Ashok,

    Thanks for chiming in here and providing solution.

    Hi @propages,

    Test the solution provided by @Ashok and let me know whether it works for you or not. Use the following getIsCrawler() function if you want it to work only for Google's crawler, Visit this page to see different types of Google crawlers which you can use in the following code.

    function getIsCrawler($userAgent)
    {
    	$crawlers = 'Google|Googlebot';
    	$isCrawler = (preg_match("/$crawlers/", $userAgent) > 0);
    	return $isCrawler;
    }

    Best Regards,

  • propages

    Hi Ash,

    Thanks for the prompt response re: Gravity Forms + other shortcode. Great solution!

    Also I tried it here:

    http://jonesl.profitnesspages.com/fat-burn-tips/

    The content on the page above is within [level-gold] [/level-gold] tags, and when I spoof my user agent as Googlebot or any other crawler, it still shows no content.

    Any suggestions on this?

    I feel we're close to getting this working really well.

    Regards,
    Lloyd

    PS,

    Here's what *should* be visible to any search engine crawler, but not humans:

    Burning fat is the ultimate goal of any weight lost program.. It gathers in your thighs, in beer bellies and stomach areas. One pound of fat is about 3555 calories and each person burns calories at a different rate. So, losing fat and weight is a two prong approach, spanning diet and exercise.<img class="alignright  wp-image-39" alt="604x663-FatBurn" src="http://template.profitnesspages.com/wp-content/uploads/sites/12/2013/09/604x663-FatBurn.jpg" width="362" height="398" />
    
    The first part of losing weight is eliminating your stores of fat by depriving your body of unnecessary fat in your diet. This means eating healthy with fresh foods, skipping heavily processed food with added fats and sugars. For coffee drinkers, this includes reducing the amount of sugars you put in your coffee. The following are some ways you can reduce the amount of fat in your diet:
    <ul>
    	<li>Decrease the amount of sugar you put in foods</li>
    	<li>Eat vegetables at every meal</li>
    	<li> Intake more protein-chicken, beans, etc—so you don’t feel hungry.</li>
    	<li>Take your lunch to the office so that you can control what you put in the food</li>
    	<li>Substitute ingredients in family favorites for a lower calorie version, such as putting applesauce in cakes to make it moist instead of butter</li>
    	<li>Keep carbs for days you exercise.</li>
    	<li>Try to eat every two to three hours to help keep energy up</li>
    	<li>Count calories.</li>
    	<li>Calculate the calories it took to maintain your weight and reduce your intake by 500 calories at least per day.</li>
    	<li>Substitute spaghetti squash for pasta</li>
    	<li>Drink water instead of sugary sodas, juices and sports drinks.</li>
    	<li>Don’t’ eliminate all fats in your diet as your body needs them. Instead, aim to consume low amounts of healthy ones.</li>
    	<li>An example of a healthy low fat breakfast is eggs and a cup of fruit. Dinner might be seasoned chicken with pureed cauliflower and carrots.</li>
    </ul>
    The second part of the fat burning equation is to move your muscles with exercise. This can be a variety of workouts that you do on a daily basis. Ideally, you should vary the workouts each day, such as rotating cardio with strength training.
    <ul>
    	<li> Keep a log of your workouts</li>
    	<li> Count the calories you burn through exercise. Use this as motivation to exercise.</li>
    	<li> Don’t expect your body to show your weight lost overnight. Give it some time. It may take a few weeks to see a visible reduction.</li>
    	<li> If you require immediate results, get out a tape measure before you start to exercise and measure your waist, chest, thighs and arms. After two weeks of following both a healthy diet and exercising, then remeasure.</li>
    </ul>
    Combining the two will yield the strongest and fastest results in fat burning. Eating right gives your body the fuel it needs to let go your stores of fat. Burning fat is ultimately up to you. You can do it.
  • DavidM

    Hi propages,

    Hope you don't mind my stepping in as well, but I was thinking, for testing purposes, possibly you could try using a simple shortcode to see it works?

    Perhaps the following basic example?

    //[bot-shortcode]
    function bot_shortcode( $atts ){
    	return "Google bot should see this!";
    }
    add_shortcode( 'botshortcode', 'bot_shortcode' );

    With that you could try using the [botshortcode] on the page and see how it displays.

    Oh, I guess you'd need to change the preg_replace function as well:
    $content = preg_replace('/\[[botshortcode^\]]*]/', '', $content);

    Anyway, just my thoughts on a way to possibly debug. Hope it helps.

  • Ash

    Hi @propages

    I have tested with user agent add on in firefox and worked fine for me. Also, I am asking another staff to test this for mr.

    @Vinod Dalvi, would you please test the above solution for me?

    As this is an interesting idea, I am pretty much excited to make it working :slight_smile:

    I am testing this on a multisite subdomain, and modifying the theme's functions.php file - should the multisite affect anything?

    It should not affect as long you use the active theme's functions.php of that subsite. If you're not sure, you can use mu-plugins - it doesn't depend on theme.

    If it still not fixed, would you please share me your ftp details with me so that I can play a little?

    To send details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash
    Details: Send all required details (admin info and/or ftp details) with a link of this thread, so that I can track.
    Also post a note here once you send the info.

    I will be happy to take a look :slight_smile:

    Cheers
    Ash

  • propages

    hi there!

    It looks like it's just my plugin that's being strange then!

    I tried a slightly different solution by using your "is_bot()" function in my code, so something like:

    <?php
    if(current_user_on_level( 1) || is_bot() ) {
    
    //SHOW THE CONTENT
    
    }
    else
    {
    //SHOW  NOTHING
    }

    I was forced to use this method (above) as the content I'm working with on the page is hard-coded into a WP template (rather than a "Page" created via the Wordpress editor) - so to block it I use "current_user_on_level(1)" to make sure they're a paid member, and use "is_bot()" to see if they're a bot. If they're not either of those, they don't see the content!

    Cheers for the help everyone!

    Do you think this functionality can be worked into the next official version of the Membership plugin?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.