Add a link to the logged in page (login-form)
-
<!-- wp:paragraph --> <p>function custom_login_form_shortcode( $atts ) {<br>if ( is_user_logged_in() ) {<br>// display your link to the internal documents<br>$link = '<a href="LINK_TO_INTERNAL_DOCUMENTS">Go to Internal Documents</a>';<br>return $link;<br>} else {<br>// display the Simple Membership login form<br>$args = shortcode_atts( array(<br>'redirect' => '',<br>'redirect_page_id' => '',<br>'show_title' => '1',<br>'show_reg_link' => '1',<br>'layout' => '1',<br>'login_redirect_url' => '',<br>), $atts );<br>return swpm_login_form( $args );<br>}<br>}<br>add_shortcode( 'custom_login_form', 'custom_login_form_shortcode' );</p> <!-- /wp:paragraph -->
Hi team,
I run Simple Membership on my WordPress installation and everything runs as expected.
The only thing I have troubles with is my user can login via a button on the main website. Works fine. Our can only login and logout, nothing else.
Now, if someone is loged in in the protected area and navigate to the main website without press the button to logout the user is still logged in. This is actually okay, but if he press the button to login again he get’s the info saying he is login as .. [name] and the message that he’s still logged in with the link to “Logout”. In this case I would like to add – besides the logout link – a link and message to bring him back to the internal documents (protected area).
I tried with the following snippet – see below:
The link “Go to Internal Documents” works (with the snippet below) but if I press the button with the user login again I get an error message:
jquery.min.js?ver=3.6.1:2 Uncaught ReferenceError: swpm_logged_in is not defined.I think my intention is simple. I would only have a link in the login-form when users are logged in to get the user back to the protected area. This is a page.
Could you maybe give me hint how this is easily managed?
See my print screen to see what I mean:
https://www.dropbox.com/s/rzs2xydsiwvx85n/SWMP_loggedinUser_22032023.png?dl=0Many thanks in advance. Besides that, I am very happy with this plugin. It’s great!
Kind regards,
Brigitte<!-- wp:paragraph --> <p>function custom_login_form_shortcode( $atts ) {<br>if ( is_user_logged_in() ) {<br>// display your link to the internal documents<br>$link = '<a href="LINK_TO_INTERNAL_DOCUMENTS">Go to Internal Documents</a>';<br>return $link;<br>} else {<br>// display the Simple Membership login form<br>$args = shortcode_atts( array(<br>'redirect' => '',<br>'redirect_page_id' => '',<br>'show_title' => '1',<br>'show_reg_link' => '1',<br>'layout' => '1',<br>'login_redirect_url' => '',<br>), $atts );<br>return swpm_login_form( $args );<br>}<br>}<br>add_shortcode( 'custom_login_form', 'custom_login_form_shortcode' );</p> <!-- /wp:paragraph -->
The page I need help with: [log in to see the link]
- The topic ‘Add a link to the logged in page (login-form)’ is closed to new replies.