i hope somebody will help, i am haven’t php talent, attempt with some pattern with out success.
i’ve a CPT with metafield “e mail” the place saved consumer e mail .
does its potential to limit submit url for these submit.
i imply.. opening cpt url , if consumer is logged-in and postmeta (contained in the submit) = current_user_email .. submit is opening, in any other case redirect to /account.
many thanks
(The snippet is working, i ask you for higher evaluation)
‘
add_action( 'template_redirect', 'redirect_different_post_meta' );
operate redirect_different_post_meta() {
$current_user = wp_get_current_user();
$currentemail = $current_user->user_email;
world $submit;
if(!current_user_can('administrator')) {
if ( $post->post_type == 'cpt_slug' ) {
$postemail = get_post_meta($post->ID, 'e mail', true);
if($currentemail != $postemail) {
wp_safe_redirect( '/my-account' , $standing = 302 );
exit;
}
}
}