WordPress.org

Ready to get started?Download WordPress

Forums

Add Link to BP Sliding Login Panel to Access Dashboard Page for WP User Frontend (4 posts)

  1. globalgamecast
    Member
    Posted 1 year ago #

    Hello.

    I am using a combination of the BuddyPress Sliding Login Panel (BPSLP) and a plugin called WP User Front End that apparently gives users the ability to create and edit posts from the frontend without switching to the standard WP Dashboard.

    I have created the page called "Dashboard", in which, according to the plugin instructions, I insert the shortcode [wpuf_dashboard]. This works fine, but I want to add the "User CP" link to the BPSLP under "Activity".

    The follwing link code in the BPSLP adds the link that takes the user to http://www.domain.com/members/username (i.e. the member's profile page so that they can enter info under "What's New" remembering that we've told BP which page to link to under BP Settings/Pages).

    <li><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG ?>">Update My Status</a></li>

    I tried defining a new BP page using:

    define( 'BP_DASHBOARD_SLUG', 'dashboard' ); but that doesn't create a link to the http://www.domain.com/dashboard/ page, it ends up linking to to http://www.domain.com/members/username/BP_DASHBOARD_SLUG page, which of course, does not exist, nor do I want it to.

    Not knowing php, and having already tried inserting a simple HTML link, I was hoping someone could help me with an easier way to code a

  2. command that would simply create the label "User CP" and link to the http://www.domain.com/dashboard/ page I created for the WP User Front End plugin.

    my site is http://www.globalgamecast.com if you want to check it out.

    Thanks

  • bcworkz
    Member
    Posted 1 year ago #

    I'm unsure of your context, so I may be wrong. If your link works as is for status updates, try this for dashboard:
    <li><a href="<?php echo site_url() . '/dashboard/' ?>">User CP</a></li>
    I don't see any point in defining your own constant unless you plan to use it in other places and would want to easily update the value in the future.

  • globalgamecast
    Member
    Posted 1 year ago #

    @bcworks I so appreciate your reply! I did not know how to call the URL using php, and thanks for showing that to me. And you are correct that it makes no sense to define my own constant. The only thing is that in this scenario, we only want the link to show only when the user is logged in, so wouldn't we need to still have the echo bp_loggedin_user_domain() portion of the code or something similar?

  • bcworkz
    Member
    Posted 1 year ago #

    I'm not familiar with BP functions, but from the name, it appeared to return an url including /username/, so I substituted site_url() to get the url you wished. I didn't think it managed the display by whether the user was logged in, but then what would it display without a user? (no answer required) It would leave some broke html if it returned nothing, I suppose it may return the root domain only.

    In any case, a better way to control display by whether logged in or not is to remove the entire list element when not logged in, so do something like:

    <?php if ( is_user_logged_in()) {
      $url = site_url() . '/dashboard/';
      echo "<li><a href='$url'>User CP</a></li>";
    } ?>
  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags