I have 2 projects, one in Wordpress, and the other one in Laravel 4.2.
Recently i had to merge both projects into one Laravel 4.2 App using jgrossi/corcel. This was my only option.
Everything works fantastic! I can even post directly into Wordpress without logging into Wordpress to get posts, comments, etc.
But there is something I can't figure out. Wordpress is using Jetpack for subscribers. The laravel app needs a field to add more subscribers. I have very little experience in Wordpress.
Is it possible to add subscribers from outside Wordpress directly into the database? If not, is there a way to use a Jetpack plugin outside of Wordpress?
Yes you can add new users in database with subscribers role.
Wordpress stores the users data in wp_users table and its meta info in wp_usermeta. So follow the following steps
Add a new entry in wp_users table. As a sample here is entry from my wp_users table. You can submit values for these attributes using your normal laravel form with post request.
Add its related data in wp_usermeta table. Here you need to set two key value attributes against user_id of newly inserted record.
meta_key = wp_capabilites and meta_value = a:1:{s:10:"subscriber";b:1;}. As you can note the meta_value for wp_capabilities is in serialzed form.
meta_key = show_admin_bar_front and meta_value = true.
So you added a new user with subscriber role.
Related
I'm trying to insert / modify / delete items from a Wordpress menu from a MYSQL query in a separate WordPress file.
Does anyone know how wordpress menus work at the database level?
They're nothing else than a default postype, specifically: nav_menu_item.
So like the rest of the postypes they are in the post table or wp_posts if you use that prefix.
As all the rest of postypes their meta values are stored in postmeta/wp_postsmeta with the corresponding id.
I know I can extract Sales Order data in OpenCart database, in table shop_order and shop_order_product.
Is it possible to differentiate which user creates the sales order?
I don't think there's an option to identify which admin user created the order. You may need to code it yourself. The below steps may help you.
Add 2 new fields created_user_id and updated_user_id in order table - with default value as 0.
Update the admin/model/sale/order.php to insert values to those fields as $this->user->getId(); (addOrder and editOrder functions ).
Add a new field user_id in order_history table - with default value as 0.
Update the admin/model/sale/order.php to insert value to that field as $this->user->getId(); (function: addOrderHistory).
You can do these by directly modifying the files or using vqmod. If it's done via vqmod then it'll be easier for you to make changes during opencart version upgrade.
Opencart: Vqmod tutorial
Have a nice day!!
By default, there's no way to know which admin an order is created by, or even that the order isn't created by the user (other than the IP would be that of the admin). You could in theory add the user_id to the shop_order table, and pass that to the manual order editor when it creates the orders
i have 2 wordpress websites A and B.
if A somehow changes (adding a post , editing a post , deleting a post ) , B needs to change as well .
so in A by using a php robot which is checking database every couple of minutes , i,ve created a json feed for added and edited posts of A .
it's easy to track added/edited posts by checking wp_posts table . but i can't find a way to know which posts have been deleted ( Delete Permanently ).
this script is suppose to be portable and usable for people who are not programmer , so i dont want to use wordpress functions or do any change/addition to wordpress system .
so is there any way to find deleted posts by checking the database or something like that ?
You can check for posts in the trash by using the query:
SELECT * FROM `wp_posts` WHERE `post_status` = 'trash'
but if you are trying to find posts that have been removed from the database you will need to either track the missing IDs in the wp_posts table or add some functionality to track when a post is deleted. You can do this by using the delete_post action hook in your theme:
function my_tracking_function() {
// Put ID into new database table
}
add_action( 'delete_post', 'my_tracking_function', 1 );
And then pass that table to the other site for processing. Once both sites are synced you can run a cleanup routine to empty the tracking table. I realize that this is partially using Wordpress functionality, but the passing of the table data can be done outside of Wordpress using SQL.
I am looking around the code in WordPress and not sure where to look and how to complete what I am doing.
I have a custom table in Wordpress that I have created, lets call it MyCustomTable. I have some data that I want to insert in to a table when the user registers.
I want to add an ID this is auto increment and done by the table so not a problem, and want to also add in the userid and a hardcoded user group.
So when user registers the following is passed to the database.
INSERT INTO MyCustomTable
VALUES (this will be autoid so not needed in insert, UserID ,Hardcoded membergroup);
Where or how to do this?
Use the user_register hook for the trigger.
If you need help with custom queries, look here
Trying to import members to my website which is using buddypress from an sql dump. I tried inserting the details in wp_xprofile_data and wp_users tables but it is not showing up in buddypress members area. How can I solve this problem?
I believe they need an entry in wp_usermeta -> meta_key = last_activity & meta_value = 2012-06-04 21:51:03
before they will show up any where.
So if they haven't logged in at least once, they won't show up.
As part of your import, create a last_activity entry.
Depending on how you have BP set-up, you may also need to 'activate' members.