• Resolved francoc30

    (@francoc30)


    Hi,
    I use W3 Total Cache on my membership site. I place shortcode swpm_mini_login in the sidebar. Because the display of the shortcode is dynamic, W3TC cached pages does not properly display user login status. i.e. even a user logged in, the shortcode still display the Join Us/Log in text instead of the user name.

    W3TC support provided a solution. But it requires me to add a couple of lines of code to the php function of the shortcode swpm_mini_login. Can you direct me where is this function located so I can make the change. Also if you can provide some information as how best to do this, will be much appreciated.

    Is there a native Simple Membership solution to the problem?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi, have you tried to implement the following suggestion?

    https://simple-membership-plugin.com/w3-total-cache-compatibility-simple-membership/

    Regards.

    • This reply was modified 3 years, 2 months ago by mbrsolution.
    Thread Starter francoc30

    (@francoc30)

    Yes mbrsolution, the above entries are in the Rejected Cookies field in the Page Cache.
    W3TC caches the whole page which is a static page. But the swpm_mini_login shortcode is in the widget in the sidebar, and the content is dynamic to reflect the user login status.

    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for providing more information. I have submitted a message to the developers to investigate further your findings.

    Kind regards.

    Plugin Author wp.insider

    (@wpinsider-1)

    Hi, The following shows where the code for the mini login shortcode is:

    https://github.com/wp-insider/simple-membership/blob/c17fcc101d8ce6bb0f95f7592069fb9279f48e63/simple-membership/classes/shortcode-related/class.swpm-shortcodes-handler.php#L117

    There is also the following filter hook available. You can potentially use this filter hook to override and output a customized code for the mini login:

    
    swpm_mini_login_output
    

    On a side note: what did they recommend you to put in the code for the caching?

    Thread Starter francoc30

    (@francoc30)

    Hi @wpinsider-1,
    Thanks for the information. I am trying to confirm with W3TC support to see if that is how this can be done. Among other things I was told to wrap the coding of the swpm_mini_login shortcode with <!– mfunc xyzsecurestring –> and <!– /mfunc xyzsecurestring –> for example:

    <!– mfunc xyzsecurestring –>

    <?php
    class SwpmShortcodesHandler {
    	public function __construct()
    codes ….
    public function 1 (…) {…}
    public function 2 () (…) {…}
    public function xyz_show_mini_login_sc () (…) {…}
    public function 4 () (…) {…}
    public function 5 () (…) {…}
    }
    <!– /mfunc xyzsecurestring –>

    I don’t see the closing tag ?>. Is it necessary? I am not a developer, so don’t know this syntex.
    I also don’t know how to use the hook you mentioned. A little direction/guidance would be appreciated.

    Plugin Support mbrsolution

    (@mbrsolution)

    Hi, just touching base with you. Did you manage to fix your issue?

    Regards.

    Thread Starter francoc30

    (@francoc30)

    Hi,
    I would like to try the hook that wp-insider mentioned in his reply. (swpm_mini_login_output) But I need some instructions as how to do it. Can you help?

    Plugin Author wp.insider

    (@wpinsider-1)

    The recommendation that you posted is not very clear to me so I don’t really know how best to handle it. You could try adding something like the following to your site’s functions.php file to wrap the mini login output with their special string:

    
    function my_customized_mini_login( $outuput ){
        $output = '<!– mfunc xyzsecurestring –>' . $outuput . '<!– /mfunc xyzsecurestring –>';
        return $outuput;
    }
    add_filter( 'swpm_mini_login_output', 'my_customized_mini_login');
    

    Please note that I didn’t test this code so I don’t know if it works or not. I am just giving the example to show how the login shortcodes output can be wrapped with the string that they recommended. Normally, for custom coding tweaks, it is better to hire a developer who can do the customized coding and testing for your site’s current setup.

    Thread Starter francoc30

    (@francoc30)

    Thanks wpinsider-1. I copied your code to the function.php file in my child theme. I don’t know where to put the hook swpm_mini_login_output so it can be triggered. I put it in my sidebar as widget (text shortcode), but it just displayed the actual text of the hook. Hope you don’t mind giving me another pointer.

    Plugin Support mbrsolution

    (@mbrsolution)

    @francoc30, all you have to do is add the mini login widget shortcode [swpm_mini_login]to the sidebar. The shortcode will trigger the function you added to the functions.php file. The following instructions can help you further.

    https://simple-membership-plugin.com/adding-mini-login-widget-sidebar-header-footer/

    Kind regards.

    Thread Starter francoc30

    (@francoc30)

    Hi @mbrsolution,
    I am not talking about the shortcode [swpm_mini_login] which I already used in the sidebar widget. I am referring to the hook swpm_mini_login_output that wpinsider-1 suggested me to use. Can you pass my question to him/her please?

    Plugin Author wp.insider

    (@wpinsider-1)

    That hook is triggered from the shortcode that @mbrsolution suggested.

    I don’t really know what other pointers I can provide from the top of my head. This topic is now going beyond the scope of the free support unfortunately. You can use a paid support ticket to get further help if you wish to.

    Thread Starter francoc30

    (@francoc30)

    Hi wpinsider-1,
    Thanks for your response. I appreciate your help. I’ll further test things out.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘php function location for swpm_mini_login shortcode’ is closed to new replies.