New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wplf-form post type unpublic #23

Closed
timiwahalahti opened this Issue Oct 25, 2016 · 9 comments

Comments

Projects
None yet
3 participants
@timiwahalahti
Copy link
Member

timiwahalahti commented Oct 25, 2016

I think that forms should not be public. In most of the use cases (at least when i'm using), those are used via shortcode rather than linking directly to single form. Public single forms shows up in search engines and sitemaps, which isn't that nice. Especially if theme developer has forgotten to style basic single page for some reason.

Antti likes to have preview of form, and that's important in my opinion too. Preview can't be achieved unless post type is public, but maybe we could make a redirect when entering single form if you're role is subscriber or you haven't logged in. Other possible way that comes to my mind, is render form in html below editor while editing it. Kinda same way as field detector works now.

@timiwahalahti

This comment has been minimized.

Copy link
Member Author

timiwahalahti commented Oct 25, 2016

Oh, actually. Making a redirect isn't by far best practice in this situation, setting 404 would be a much better solution (props @TeemuSuoranta).

add_action( 'wp', 'maybe_show_404_on_wplf_single' );
function maybe_show_404_on_wplf_single() {
  if( !current_user_can( 'edit_post' ) && is_singular( 'wplf-form' ) ) {
    global $wp_query;
    $wp_query->set_404();
  }
}

This way post type is public, preview and single view works for logged in users, but visitor gets 404. Google does not index 404, but there may still be issues with some plugins that generates sitemaps. However it's better situation than current, at least in my opinion.

There is also need for setting to disabling this feature on single forms, maybe a filter to disable it in all forms. Also a notification or some sort of message in editor or form view is needed to indicate that this don't work unless you are logged in.

Any thoughts? Because of time related matters, I wouldn't want to do PR if it wont be merged.

@anttiviljami

This comment has been minimized.

Copy link
Collaborator

anttiviljami commented Oct 25, 2016

LGTM! If you can test and PR this, I'll gladly merge this :)

Awesome !

@timiwahalahti

This comment has been minimized.

Copy link
Member Author

timiwahalahti commented Oct 25, 2016

There's PR now, #31.

I'we tested it, but maybe it would be good if you and @k1sul1 could test it also before merge?

@k1sul1

This comment has been minimized.

Copy link
Member

k1sul1 commented Oct 26, 2016

Seems to work, just tested. Looks very good.

However, do we really need yet another metabox? Right now we have 3 metaboxes on the side, wouldn't just one be enough?

metaboxes

Or is it just me?

@k1sul1

This comment has been minimized.

Copy link
Member

k1sul1 commented Oct 26, 2016

I found a bug in vigorous testing.

bug

This text seems to appear on other post types too, such as page.

@anttiviljami

This comment has been minimized.

Copy link
Collaborator

anttiviljami commented Oct 26, 2016

We definitely don't need the metabox. I don't see a use case for /wplf-form/myform urls. Better to just hide them

@timiwahalahti

This comment has been minimized.

Copy link
Member Author

timiwahalahti commented Oct 26, 2016

@k1sul1 good catch! That's what happens when you submit PR after midnight 😹

If metabox if removed, maybe that filter and notice should be kept tho?

@anttiviljami

This comment has been minimized.

Copy link
Collaborator

anttiviljami commented Oct 26, 2016

👍 for the notice

Having the filter is ok. Just make sure forms are non-public by default. :) Now it seems to be the other way round.

Thanks <3

@timiwahalahti

This comment has been minimized.

Copy link
Member Author

timiwahalahti commented Oct 26, 2016

PR is now updated; meta box got removed and permalink notice in post.php fixed to show up only when editing wplf-form post type.

Forms have been non-public, but I did double-check that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment