latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

BP redirect not working for create Blog

Home Forums Community Forum BP redirect not working for create Blog

This topic contains 48 replies, has 5 voices. Last updated by  David Hunt 4 years, 4 months ago.

Page 2 Of Topic Replies

Viewing 23 replies - 26 through 48 (of 48 total)
Author Replies
Author Replies
Posted: Friday Aug 24th, 2012 at 10:58 am #22981
David Hunt
Username: okso

Thanks Cristian. Let’s hope Jason can shed light! I won’t do anymore fiddling now until I hear from you.

Posted: Saturday Aug 25th, 2012 at 6:31 am #23038

Cool.

Since you did customized this one a bit already, it’d still be good to do a clean test installation as I mentioned before, and test how a clean WP, BP, s2 behave with the setup you want. See if it’s the same as what you have in this customized installation, to rule out the customizations as the source of the problem, basically.

Posted: Monday Aug 27th, 2012 at 8:50 am #23168
David Hunt
Username: okso

Hi Cristian,
Just to let you know I’ve now tested the config on two separate sites, the same issue remains…

for an S2 Level 1 member (when the membership level 1 blog allowance is set to 0) I get 404, not a redirect to options.

for an S2 member (who has exceeded their membership level blog allowance) I get 404, not a redirect to options.

I think the thing to do now is get a clear instruction as to what the software should do in these two scenarios.

Thanks. David

Posted: Monday Aug 27th, 2012 at 6:49 pm #23209
Staff Member

Thanks for the heads up on this thread.

My investigation of this installation turned up the following issues.

1. No URI restriction – RESULT = 404 (makes sense as they don’t have access yet)

Correct. In the case of BuddyPress, the /create/ URL will result in a 404 error introduced by BuddyPress itself, whenever access to create blogs is not possible for the current user (for any reason). So if s2Member is configured NOT to allow blog creation access, BuddyPress will interpret this as a 404 error, because the page used to create a new blog does not even exist in the eyes of BuddyPress.

As you mentioned, this is the expected behavior.

2. With URI restriction /microsite/create/ – RESULT = S2 tries to redirect them with this url but fails to complete redirection.

http://xxxxxx/membership-options/?_s2member_seeking%5Btype%5D=ruri&_s2member_seeking%5Bruri%5D=L21pY3Jvc2l0ZXMvY3JlYXRlLw%3D%3D&_s2member_seeking%5B_uri%5D=L21pY3Jvc2l0ZXMvY3JlYXRlLw%3D%3D&_s2member_req%5Btype%5D=level&_s2member_req%5Blevel%5D=1&_s2member_res%5Btype%5D=ruri&s2member_seeking=ruri-L21pY3Jvc2l0ZXMvY3JlYXRlLw%3D%3D&s2member_level_req=1 

This would also be the expected behavior. s2Member will redirect the user to the Membership Options Page, because they do not have access (i.e. in this case there IS a URI Restriction implemented within s2Member), and therefore s2Member will intervene, by redirecting anyone without access.

However, what’s NOT working properly, is the redirection URL itself, which in this case results in a 404 error. Upon a deeper investigation, I find this URL /membership-options/ no longer exists. It appears that you renamed this page to /options/ instead, which does work properly.

I updated your s2Member General Options, and s2Member now has the right Membership Options Page (i.e. /options/, instead of /membership-options/). Please let me know if problems persist.

Posted: Tuesday Aug 28th, 2012 at 7:43 am #23261
David Hunt
Username: okso

Hi Jason,
Thanks for taking the time to pick this up. I had a look and from what I can see I still have the same issue. A few notes first though.

re: 2. With URI restriction /microsite/create/ – RESULT = S2 tries to redirect them with this url but fails to complete redirection.

This was happening because the url length with /membership-options/ was exceeding Apache url length limit. I found that when I renamed this to /options/ I could get away with this BUT Cristian advised me to use the hack in mu http://paste.pagelines.com/3n4

That fixed left me with this final 404 issue, which is importent for me to resolve, to make sure users get sufficient feedback when they reach their membership blog allowance to upgrade their membership.

404’s:
for an S2 Level 1 member (when the membership level 1 blog allowance is set to 0), I get 404, not a redirect to options.

for an S2 Level 1 member (who has used their membership level blog allowance, if blog allowance set to 1) I get 404, not a redirect to options.

Please let me know what you’d like me to do. I’m still not absolutely clear from your notes what the software should do in these use cases.

Kind regards, David

Posted: Friday Aug 31st, 2012 at 5:53 am #23663
David Hunt
Username: okso

Hi Jason & Cristian, can you task me with a lead on making some progress on this. Kind regards, David

Posted: Saturday Sep 1st, 2012 at 9:31 pm #23810
Bruce
Username: Bruce
Staff Member

Hi David,

Can you try changing your Membership Options Page to a different page, saving, and then switching it back? s2Member caches it’s options, so the slug for the page may not have changed when Jason saved the options.

Let me know if that fixes it.

Posted: Sunday Sep 2nd, 2012 at 5:12 am #23839
David Hunt
Username: okso

Hi Bruce, I’ve done as you’ve said, changed options page and saved, then set back o options and re saved. Still no change, I get /create/ if user hasn’t exceeded their allowance and 404 if they have.

Posted: Sunday Sep 2nd, 2012 at 9:28 pm #23885
Bruce
Username: Bruce
Staff Member

Hi David,

Sorry for the delayed response

Hi Bruce, I’ve done as you’ve said, changed options page and saved, then set back o options and re saved. Still no change, I get /create/ if user hasn’t exceeded their allowance and 404 if they have.

Thanks for clearing that up.

Jason explained this occurrence above, as a way of BuddyPress protecting its blog creation page. s2Member does not have any control of this, as s2Member only protects content based on Membership Levels / Custom Capabilities. If you’d like to change this, you’ll need to hook into BuddyPress. I believe that the functionality of the /create/ page is within buddypress/blogs/create.php.

Does that answer your question?

Posted: Monday Sep 3rd, 2012 at 4:19 am #23911
David Hunt
Username: okso

ok, can I have some help here then. Is there a way to get S2 to throw up anything that I can catch or use to redirect members either to the S2 options page or a custom pro form to upgrade their S2 membership? It seems a bit crude that S2 promotes the support of ‘Maximum Blogs Allowed’, but user gets a 404 when the allocation is exceeded. How have other customers responded to this? Any leads appreciated.

*I know I’ve mentioned this before, I’m getting this from debug:
NOTICE: wp-content/plugins/s2member/includes/classes/cache.inc.php:97 – Undefined variable: cache_needs_updating

  • This reply was modified 4 years, 4 months ago by  David Hunt.
Posted: Tuesday Sep 4th, 2012 at 6:54 pm #24081
Bruce
Username: Bruce
Staff Member

Hi David,

Sorry for the delay

I took another look at the BuddyPress code for the /create/ page, and it appears that it is actually controlled by the BuddyPress theme you are running. In the default BuddyPress theme, when the user accesses the create blog page, they are given the message “Site registration is currently disabled”. I would take a look into the file within your theme called /blogs/create.php, and run a search for 404. If there is a trigger for the 404 page, you can post the code here, within a reply to this post and we’ll see if we can fix it.

How have other customers responded to this? Any leads appreciated.

A lot of people would conditionally hide links to the registration page using something like get_site_option('registration'); # if this == 'none' then they cannot make any more sites.. This can also be used for your site.


s2Member only controls the “On/Off switch” for the BuddyPress site creation functionality. Therefore, if your theme gives the user a 404 if it is off, then the same will happen when they run out of “credits” to create a site.

*I know I’ve mentioned this before, I’m getting this from debug:
NOTICE: wp-content/plugins/s2member/includes/classes/cache.inc.php:97 – Undefined variable: cache_needs_updating

I’m going to look into this within the following day and see what might be happening here within s2Member’s code (I’m not familiar with this occurrence). If I cannot get you a resolution for this within the next 1-2 days I’ll contact Jason once again to get his opinion on it.

Thanks for your patience.

Posted: Tuesday Sep 4th, 2012 at 8:01 pm #24088
Bruce
Username: Bruce
Staff Member

Hi David

From my last post:

I’m going to look into this within the following day and see what might be happening here within s2Member’s code (I’m not familiar with this occurrence). If I cannot get you a resolution for this within the next 1-2 days I’ll contact Jason once again to get his opinion on it.

Investigation Complete.

From looking at the file /includes/classes/cache.inc.php, it appears that the variable $cache_needs_updating is set from within the file based on if() statements. This variable being undefined does not affect anything because it is only checking to see if the variable is TRUE.

I’m going to contact Jason about changing the code slightly within this file so that the above error does not show up within the debug, as it is not affecting anything.

Posted: Wednesday Sep 5th, 2012 at 3:29 am #24124
David Hunt
Username: okso

Hi Bruce, thanks for looking into this.

Here’s my create php http://paste.pagelines.com/6co
It comes from the standard Buddypress template http://wordpress.org/extend/plugins/bp-template-pack/

Let me know if you need more. Full access was provided with the original pro support contact on this thread.

Posted: Wednesday Sep 5th, 2012 at 3:53 pm #24202
Bruce
Username: Bruce
Staff Member

Hi David,

Thanks for the information

I have uploaded the following code to your website within an s2hacks.php file in /wp-content/mu-plugins/

I tested this on your site and it seems to be working correctly. Let me know if you have any issues.

<?php
/**
* Hack authored by Bruce (Support Rep) on the s2Member Forums.
* If problems persist, add a topic reply to http://www.s2member.com/forums/topic/bp-redirect-not-working-for-create-blog/ or create a new topic
*/
add_action('wp_loaded', 's2hack_redirect_buddypress_404_create');
function s2hack_redirect_buddypress_404_create()
	{
		if($_SERVER&#91;"REQUEST_URI"&#93; === '/microsites/create/' && !bp_blog_signup_enabled())
			{
				header('Location: http://'.$_SERVER&#91;'SERVER_NAME'&#93;.'/options/');
				exit();
			}
	}
?>
For other users having this problem:

I will be creating a Knowledge Base Article on this within 1-2 weeks outlining ways to overcome BuddyPress’s 404 error here.

If you have any further problems, please reply here. :)

Posted: Wednesday Sep 5th, 2012 at 6:48 pm #24211
David Hunt
Username: okso

Hi Bruce,
I’ve tested the feature and I still get 404. I have a test user who has joined 7 blogs. If I set S2 Level 1 to 8 I get /create/, if I set it back to 7, I get 404.

Id tried to bite into the code using a redirect @line31 in create.php but didn’t have any success with wp_redirect( ‘/microsites/create’, 302 ); exit;

OK, next step?

Posted: Wednesday Sep 5th, 2012 at 8:32 pm #24227
Bruce
Username: Bruce
Staff Member

Hi David,

Sorry, I had forgotten to re-upload the file.

Should work now.

Posted: Wednesday Sep 5th, 2012 at 8:55 pm #24234
David Hunt
Username: okso

Hi Bruce,

Fantastic, it works!

While this is fresh in your mind, how easy is it to use/edit that snippet and grab the members existing S2 level, and then redirect to specific url or anchor, based on the pro form thats relevant for their requirements. I don’t see an immediate way for front end status to let a user know they are S2 Level 1 etc and they need XXX. I think this would create a better user experience if this can be done, eg. http://screencast.com/t/6MjJgZQM4U

Posted: Wednesday Sep 5th, 2012 at 9:28 pm #24239
Bruce
Username: Bruce
Staff Member

Hi David,

s2Member does pass variables as an array in the URL of the page when it has to redirect users to the Membership Options Page. However, it does require some PHP within your Membership Options Page to make use of these variables.

You can find information on these variables within your Dashboard under s2Member->API / Scripting->Membership Options Page / Variables. Let me know if you need any help with setting something up. :)

Another Thought:

You may want to put a $_GET[] variable on the end of the URL the script I posted to be able to tell when a user is just directly accessing the Membership Options Page, and when they have been redirected through that script.

Posted: Thursday Sep 6th, 2012 at 8:09 am #24303
David Hunt
Username: okso

Hey Bruce, thanks for the heads up.

So, I get we can use the S2 variables in an edited version of the redirect in our current hack. Can you take a moment to advise how I can edit options page, or other bespoke redirect page to facilitate the desired ‘land on specific’ S2 pro upgrade form.

Does it simplify the issue if I use the hack to land on new bespoke pages, just with one necessary pro form for desired upgrade, rather than use the /opions/ page?

Posted: Thursday Sep 6th, 2012 at 10:59 pm #24446
Bruce
Username: Bruce
Staff Member

Hi David,

Can you take a moment to advise how I can edit options page, or other bespoke redirect page to facilitate the desired ‘land on specific’ S2 pro upgrade form.

I wrote a quick article on using the Membership Options Variables here with some sample code that you can use to get started. I’ll update it soon to add some detail to some more things that might help you, and other s2Member users using WordPress MultiSite.

Does it simplify the issue if I use the hack to land on new bespoke pages, just with one necessary pro form for desired upgrade, rather than use the /opions/ page?

That’s really up to you, but I would suggest just adding:

?_s2member_seeking[ruri]=' . base64_encode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])

to the end of the redirect URL, which you could use within /options/ just the same as s2Member’s normal functionality. Doing the above would save time with the code on the Membership Options Page, but still wouldn’t let users know why they were redirected, which is what you’re trying to do, by what I understand.

Posted: Friday Sep 7th, 2012 at 12:30 pm #24538
David Hunt
Username: okso

Hi Bruce, thanks so much for these directions. To clarify, the ultimate desire would be to inform users why they’ve been directed away from the /create/ page to an upgrade form, so they know what’s going on. I’ll go and dig into your suggestions, please keep me updated if you have further insights.

Posted: Friday Sep 7th, 2012 at 1:27 pm #24548
Bruce
Username: Bruce
Staff Member

Hi David,

To clarify, the ultimate desire would be to inform users why they’ve been directed away from the /create/ page to an upgrade form, so they know what’s going on. I’ll go and dig into your suggestions, please keep me updated if you have further insights.

I’ll definitely post back here when I have updated my KB article. If you’d like to redirect users to your specific form, you could do so through a PHP hack (using header(‘ Location: http://url-to-form/ ‘);exit();), OR through JavaScript on your Membership Options Page using the info I provided in the KB article. I’ll update the article to show how to do that as well.

Posted: Friday Sep 7th, 2012 at 2:41 pm #24556
David Hunt
Username: okso

great, I look forward to the kb.

To create some consistency and not dupe pages, I’ve decided to go with two top level pages, using pro forms, which works beautifully for logged in and logged out/non members;

s1>s2 http://domain.com/pro-registration/
s2>s3 http://domain.com/proplus-registration/

I’ve nested that under the Pricing tab, so hopefully user will be familiar with the member levels and respective privileges. Nearly there.

Viewing 23 replies - 26 through 48 (of 48 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.