Programatically choosing Login Welcome and Membership Options pages.

Forums General Programatically choosing Login Welcome and Membership Options pages.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #500
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Cristián, many thanks for creating this excellent resource which I’ve just discovered and all the help that you have provided to the many people with questions about s2members. You have been an invaluable resource over the years to the s2member community and me in particular.

    Now to my question to anyone on this forum, I would like to programmatically select different Login Welcome and Membership Options pages based on conditionals and thus bypass the s2member admin UI for this. I have been looking for sample code to accomplish this. I suspect the code must reside as a MU plugin. Any references or suggestions on how to accomplish this?

    BTW, I am running the Pro plugin.

    Many thanks,
    Scott

    #503

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Thank you Scott! It means a lot to me that you say that. 🙂

    programmatically select different Login Welcome and Membership Options pages based on conditionals

    I recently helped Cassel with a hack to do just that: http://s2member.net/forum/redirect-if-user-does-not-have-the-correct-ccap-371#post-386

    You can customize it to your own restriction requirements and landing pages, and even add several instead of just one.

    I’m thinking about writing an add-on plugin to achieve this from the s2Member admin instead of a hack.

    I hope that helps!

    #506
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Hello Cristián,
    Many thanks for your code sample. I see you base it on CCAP which is cool and this has given me ideas for another s2m project.

    For the current site I have a lot of custom capabilities for the different courses but I’m actually using WPML to convert the English only site to multi-lingual and need to direct members in one language, say French or Spanish, to the login welcome page in their language rather than the English page. Likewise for the members option page there will be only one page for each language. In both cases I would like to direct language-specific users to their respective pages using conditionals such as:

    if ( ICL_LANGUAGE_CODE=='en' ) {  
    	// direct to English Login Welcome page url
    }
    if ( ICL_LANGUAGE_CODE=='fr' ) { 
    	// direct to French Login Welcome page url
    }

    Cheers,
    Scott

    #510

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    I see. Well, you could ask the WPML guys what the code to detect the language would be, then do the redirection. You can see the redirection line in my hack for an example. 🙂

    #511
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Hello Cristián,

    That one is easy. I can just query ICL_LANGUAGE_CODE for the single letter language code. So, for example, if I want to test if the user is in the French site I would just test if (ICL_LANGUAGE_CODE == ‘fr’). My challenge is in understanding how s2member fires the triggers that redirects the user to the members option page and how I can step in and and replace the default url if the user is in, for example, the French context. Ditto for the login welcome page. So my focus is on the s2member side and not WPML. I can see this being generally useful to anyone who needs to redirect based on any conditional that interests them.

    Your code example tests for a specific CCAP and then redirects if found. How would I change that to redirect if a specific condition is met? I guess I am trying to better understand the variable _s2member_vars.

    if (!empty($_REQUEST['_s2member_vars']) && strpos($_REQUEST['_s2member_vars'], 'ccap..ccap..element') !== false) {
       header('Location: http://mysite.org/french-member-options-page//?lang=fr');
       exit;
    }

    Many thanks,
    Scott

    #512

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Just having !empty($_REQUEST['_s2member_vars']) in the conditional will spot if the user was sent to the Membership Options Page.

    You don’t need to check for a ccap as I did in that particular case, you can just redirect the visitor to the Membership Options Page for that particular language.

    For example (untested):

    if (!empty($_REQUEST['_s2member_vars'])) {
       header('Location: http://mysite.org/'.strtolower(ICL_LANGUAGE_NAME_EN).'-member-options-page/?lang='.ICL_LANGUAGE_CODE);
       exit;
    }
    

    I hope that helps. 🙂

    #515
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Cristián,

    That helps immensely! Many thanks! I will test it.

    if ( !empty($_REQUEST['_s2member_vars'] && ( ICL_LANGUAGE_CODE=='fr' ) ) ) {
       header('Location: http://mysite.org/'.strtolower(ICL_LANGUAGE_NAME_EN).'-member-options-page/?lang='.ICL_LANGUAGE_CODE);
       exit;
    }

    In my OP I also was interested in the Login Welcome page redirection. What signals that?

    Cheers,
    Scott

    #516
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Cristián,

    This goes into the MU plugin, of course but do I need to place it in a function and add it as an action to anything?

    Cheers,
    Scott

    #517

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    No, no hook needed. Just open the PHP block as the very first thing in the file, add that code, and that’s it. Save the file with a PHP extension and upload it to /wp-content/mu-plugins/.

    #523
    Scott P
    Participant

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Thanks, Cristián. That solves the membership options side of my question. When a member logs in they are taken to the English login welcome page. How does one override that based on conditionals?

    Cheers,
    Scott

    #525

    Deprecated: wp_make_content_images_responsive is deprecated since version 5.5.0! Use wp_filter_content_tags() instead. in /nfs/c09/h02/mnt/138233/domains/s2member.net/html/wp-includes/functions.php on line 4773

    Check the $_SERVER array to see if the page requested is the Login Welcome one (look for its slug in the ‘REQUEST_URI’). http://php.net/reserved.variables.server

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.