insert custom database table

Home Forums Plugin Support insert custom database table

This topic contains 2 replies, has 1 voice, and was last updated by  kunstbada 4 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8453

    kunstbada
    Member

    Hello,

    thank you for great plugin.

    I need insert data into custom table when user update profile.
    Is it possible that I can save on the custom table?

    How can I add this code into the UMP?

    
    public function mp_seller_meta($user,$seller_key,$seller_val)
          		{
            			global $wpdb;
            			$seller_table=$wpdb->prefix.'mpsellerinfo';
            				$seller=array('user_id'=>$user,'seller_key'=>$seller_key,'seller_value'=>"customer");
            			}
    
    • This topic was modified 4 months, 2 weeks ago by  kunstbada.
    #8455

    kunstbada
    Member

    I add this code but It doesn’t work. can you tell me what is wrong?

    add_action(‘user_meta_after_user_update’, ‘user_meta_after_user_update_function’ );
    function user_meta_after_user_update_function($response){
    $userID = $response->ID;

    global $wpdb;

    $wpdb->insert(
    table=$wpdb->prefix.’mpsellerinfo’,
    array(
    ‘user_id’ => $user_id,
    ‘seller_key’ => “role”,
    ‘seller_value’ => “customer”
    ),
    array(
    ‘%s’,
    ‘%d’
    )
    );

    • This reply was modified 4 months, 2 weeks ago by  kunstbada.
    • This reply was modified 4 months, 2 weeks ago by  kunstbada.
    #8458

    kunstbada
    Member

    I changed code and it’s working well.

    function insert_mpsellerinfo_function($response)
    {

    $user_id = $response->ID;

    global $wpdb;

    $wpdb->insert(
    $table = $wpdb->prefix. ‘mpsellerinfo’ ,
    array(
    ‘user_id’ => $user_id,
    ‘seller_key’ => $seller_key,
    ‘seller_value’ => “customer”
    ),
    array(
    ‘%s’,
    ‘%d’
    )
    );
    }
    add_action(‘user_meta_after_user_update’, ‘insert_mpsellerinfo_function’);

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.