Tagged: x
-
AuthorPosts
-
June 23, 2016 at 4:26 pm #1057021
yahya92ParticipantHello there,
so I saw some of the questions here about how to put login/ register links in top bar but unfortunately the provided solutions are weak.
you see in any site we see Login and Register link and when we login we see logout link with access to user profile
how to achieve that?June 23, 2016 at 10:23 pm #1057503
Rue NelModeratorHi There,
Thanks for writing in!
To have a Register and Login link in your topbar, we must first create a shortcode that will easily handle this function. If you already have your child theme active and ready, please insert this following code in your child theme’s functions.php file.
// Custom login/logout/register shortcode // ============================================================================= function custom_loginlogout($atts){ extract( shortcode_atts( array( 'separator' => '' ), $atts, 'loginlogout' ) ); $content = wp_loginout(null, false) . ' <span class="sep">' . $separator . '</span> '; if ( is_user_logged_in() ) { $content .= wp_register('', '', false); } else{ $content .= wp_register('', '', false); } return $content; } add_shortcode('loginlogout', 'custom_loginlogout' ); // =============================================================================After adding the code above, you need to edit your topbar content, Appearance > Customize > Header > Miscellaneous > Topbar Content and insert our new shortcode:
[loginlogout separator="|"]And by default, the topbar content doesn’t display any shortcode. You also need to add this code in your child theme’s functions.php file so that our shortcode will be displayed.
// Allow shortcodes in the topbar content // ============================================================================= function allow_custom_shortcodes($contents) { $contents = do_shortcode($contents); return $contents; } add_filter('x_option_x_topbar_content', 'allow_custom_shortcodes'); // =============================================================================Please note that the register link will only appear if you allow registrations in Settings > General.
We would loved to know if this has work for you. Thank you.
June 27, 2016 at 4:01 am #1061143
yahya92Participantthanks,it works (y)
June 27, 2016 at 4:09 am #1061153
Rue NelModeratorYou’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread.June 28, 2016 at 6:50 pm #1063993
yahya92Participantthere is an issue, when the user is logged in the log in link become “manage site”, while I need it to be a link to user buddypress profile
June 29, 2016 at 1:50 am #1064393
Paul RModeratorHi,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
June 29, 2016 at 4:54 am #1064549
yahya92ParticipantThis reply has been marked as private.June 29, 2016 at 7:20 am #1064704
Paul RModeratorHi
Please change the code that pertains to Custom login/logout/register shortcode with this.
// Custom login/logout/register shortcode // ============================================================================= function custom_loginlogout($atts){ extract( shortcode_atts( array( 'separator' => '' ), $atts, 'loginlogout' ) ); $content = wp_loginout(null, false) . ' <span class="sep">' . $separator . '</span> '; if ( is_user_logged_in() ) { if ( function_exists( 'bp_loggedin_user_domain' ) ) : global $current_user; $content .= '<a href="'.home_url() . '/الأعضاء/' . $current_user->user_login . '/profile/">My Profile</a>'; else: $content .= wp_register('', '', false); endif; } else{ $content .= wp_register('', '', false); } return $content; } add_shortcode('loginlogout', 'custom_loginlogout' ); // =============================================================================Hope that helps.
June 30, 2016 at 9:44 am #1066762
yahya92Participantalthough the when I click on My Profile the link is 100% true I get 404 page!
June 30, 2016 at 6:03 pm #1067454
RadModeratorHi there,
Please replace this line of code,
$content .= '<a href="'.home_url() . '/الأعضاء/' . $current_user->user_login . '/profile/">My Profile</a>';with this one,
$content .= '<a href="'.bp_loggedin_user_domain().'">My Profile</a>';Hope this helps.
June 30, 2016 at 11:25 pm #1067922
yahya92Participantthumbs up
thank youJuly 1, 2016 at 12:59 am #1067999
Rue NelModeratorYou’re welcome!
We’re glad we were able to help you out. -
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1057021 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
