americanknight
Member
Posted 1 year ago #
I'm creating a Wiki-like site, where I want to give anyone the ability to click on an "edit this entry" link for a post. For registered and logged-in users, they're immediately be taken to the admin editing page for that post. This is working fine. But what I don't know how to do is this: For non-registered or non-logged in users, the "edit this entry" link should take them to the login/register page, and then to the editing page for that post. The problem is that the "edit this entry" link disappears for non-logged-in users. Is there a way that I can make this link always present? For me it defeats the purpose if a user has to first login and then find the post that they'd like to edit.
You could edit the theme. If logged in, show the edit link, if not, an 'edit' link to uour signup page.
http://codex.wordpress.org/Function_Reference/is_user_logged_in
americanknight
Member
Posted 1 year ago #
That's almost what I need, except that for non-logged-in users, I need the link to first take them to the login page and then directly to the edit page for the post they were viewing, as opposed to the dashboard. And I need this link to automatically work on any post, as opposed to having to hard code it on each post with individualized post numbers. Is there a way to do this?
Hmm. You can redirect the login link ( poke around the codex, it's in there), but I don't know that it'll work for people registering...
It WILL work on all posts, though. I do it to keep people off the dashboard part of my site. Integrated login on every page.
americanknight
Member
Posted 1 year ago #
Thanks for the pointer. I was able to find this:
<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>
... which is almost what I want. If I could just figure out how to redirect to the edit page for the particular post, I'll be set.
Yeah, I know how to do it in a FORM (that is, in-line login, keeps you on that page).
http://www.strangework.com/2010/03/26/how-to-redirect-a-user-after-logging-into-wordpress/
But you have to be able to pass through the current page.
americanknight
Member
Posted 1 year ago #
I figured it out. Here's my code:
<a href="http://partybaron.com/wp-admin/post.php?post=<?php the_ID(); ?>&action=edit">Edit</a>