WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Twelve
[resolved] [Twenty Twelve] Adding elements to the right side of header image (8 posts)

  1. Havends
    Member
    Posted 1 year ago #

    What I would basically like to do is to add something like:

    Welcome to MyBlogName!
    Register | Login

    for guests, and,

    Welcome USERNAME!
    Edit your profile | Sign out

    for registered users, to the right side of the header image of Twenty Twelve theme (after reducing the width of header image).
    Using solutions like:

    <?php wp_register(); ?>
    <?php wp_loginout(); ?>

    made each link appear on separate lines. I would like them to appear in the same line.

    It would be great if you could also direct me to adding a 'Header widget' that would align to the right of the header image, which would enable easy additions of links, Search box, etc.

    NB: I am currently working on the theme using Bitnami WordPress Stack. If you want, I can upload the theme files, if necessary.

  2. ThorHammer
    Member
    Posted 1 year ago #

    Try to include the content within the headers H1.

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    the default output of wp_register() is a html li element; use the corresponding parameter to remove that:

    http://codex.wordpress.org/Function_Reference/wp_register

    example:

    <?php wp_register(' ',' '); ?> | <?php wp_loginout(); ?>

  4. Havends
    Member
    Posted 1 year ago #

    Thanks a ton alchymyth! It turned out to be just the thing I needed (I am not much into php; just able to understand some parts of it as I go on reading codes). :)

    @ThorHammer Thanks for your valuable time and suggestion. :)

  5. Havends
    Member
    Posted 1 year ago #

    After searching around, the following code is what I am using now (to make it easy for other users searching for a solution).

    Please suggest a better alternative, if you have any.

    <div class="welcomein">
    <?php global $user_ID; if( $user_ID ) : ?>
    Welcome <?php global $current_user; get_currentuserinfo(); echo ($current_user->user_login); ?>
    <?php else : ?>
    Welcome to My Site!</br>Please
    <?php endif; ?>
    <?php wp_register(' ',' '); ?> | <?php wp_loginout(); ?></div>
  6. Havends
    Member
    Posted 1 year ago #

    Still one doubt...
    Using <?php wp_register(' ',' '); ?> gives me "Register" or "Site Admin".
    I am looking forward to restricting "Subscribers" from Admin pages. So, how can I display "Edit your profile" (wp-admin/profile.php) instead of "Site Admin" (wp-admin/) ?

  7. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    you could possibly add a filter function into functions.php of your theme;

    example:

    //change 'Site Admin' link and text for logged in 'subscribers' to point to 'Edit your Profile'//
    //anybody with higher capabilities such as 'contributor' and above will get linked to 'Site Admin'//
    add_filter('register','point_admin_link_to_profile');
    
    function point_admin_link_to_profile( $link ) {
    //http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table//
    //check for 'subscriber' with checking for cannot 'edit_posts'//
    if( is_user_logged_in() && !current_user_can('edit_posts') ) {
    $link = str_replace('Site Admin','Edit your Profile', $link);
    $link = str_replace('wp-admin/','wp-admin/profile.php', $link);
    }
    return $link;
    }
  8. Havends
    Member
    Posted 1 year ago #

    Thank you alchymyth! :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic