最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

I need a link that directs the user that is logged to his profile

programmeradmin1浏览0评论

I want a link in the form to an image in the frontpage, that direct the user that is logged to the subscription packages that are on its profile:

The link look like this: /?screen=acc_pay

But I want for the user part /admin/ to change depending on the user that is logged.

I am using KingComposer:

This is the page were the link should be

And this is were it should lead undependant of the user that is logged in, so I need a customized link that leads to the author page of the user that is logged

This is the result of imputing this code

<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
    echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src=".png" /></a>';
} else {
    echo '<span>Please log in</span>';
}
?>

I want a link in the form to an image in the frontpage, that direct the user that is logged to the subscription packages that are on its profile:

The link look like this: https://mywebsite.co.uk/author/admin/?screen=acc_pay

But I want for the user part /admin/ to change depending on the user that is logged.

I am using KingComposer:

This is the page were the link should be

And this is were it should lead undependant of the user that is logged in, so I need a customized link that leads to the author page of the user that is logged

This is the result of imputing this code

<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
    echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src="https://mywebsite.co.uk/wp-content/uploads/2020/10/pricing-06.png" /></a>';
} else {
    echo '<span>Please log in</span>';
}
?>
Share Improve this question edited Oct 16, 2020 at 12:02 Ramdo47 31 bronze badge asked Oct 14, 2020 at 14:52 Ramdo47Ramdo47 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You said that KingComposer will accept PHP blocks.
This will generate a link to the current logged-in user's author page:

<?php
$author_page = is_user_logged_in() ? get_author_posts_url( get_current_user_id() ) : NULL;
$acc_pay_page = $author_page ? add_query_arg( 'screen', 'acc_pay', $author_page ) : NULL;
if ( $acc_pay_page) {
    echo '<a href="' . esc_url( $acc_pay_page ) .'"><img src="account_page_page.png" /></a>';
} else {
    echo '<span>Please log in</span>';
}
?>
发布评论

评论列表(0)

  1. 暂无评论