Customer login with credentials to access news

Asked

Viewed 82 times

2

Explanation:

I have a customer registration in post_type through metaboxes, where there are the fields email and password, and the client’s name is the_title();

Goal:

I need to log in with the fields email and password and check if there are any clients (post_type) with these credentials.

Remarks:

I have a news post_type, which when they are inserted are directed to a specific client, that is, when logging in, you can only have access to news directed to the client who is logged in.

  • Someone to help me?

  • Be more specific, what have you experienced so far? Paste here your php code relating to your question

  • I’ve got people. Thanks for your attention.

  • Post the solution you found and mark as accepted. So you can help future users with the same problem :)

1 answer

0


/* Resolution I found: */

$email = $_POST['email'];
    $senha = $_POST['senha'];

    $args = array(
        'post_type' => 'clientes',
        'meta_query'=> array(
            'relation' => 'AND',
            array(
                'key' => 'email',
                'value' => $email,
                'compare' => '='
            ),
            array(
                'key' => 'senha',
                'value' => $senha,
                'compare' => '='
            )
        )
    );  

    $cliente_args = new WP_Query( $args ); 



/*Buscar noticias que possuem o ID (GET) no metabox; */ 
            $args = array(
                'post_type' => 'noticias',
                'meta_query'=> array(
                    array(
                        'key' => 'clientes',
                        'value' => $_GET['id'],
                        'compare' => '='
                    )
                )
            );  
            $clientes = new WP_Query($args); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.