WordPress.org

Ready to get started?Download WordPress

Forums

How to add user page with my plugin (3 posts)

  1. pstanev
    Member
    Posted 1 year ago #

    Hi I want to add userpage with my plugin i try like 10 different functions ,but non of them work.

    Here is picher of what i want to do when my plugin is on:
    http://store.picbg.net/pubpic/70/CF/9cf3dea132b070cf.gif

  2. bcworkz
    Member
    Posted 1 year ago #

  3. finnj
    Member
    Posted 1 year ago #

    Hi, i use the below code in my plugin to create the page that contains the shortcode for the plugin, if the page is not there already - mybe you can use some of it:

    // Check if page containing [frontier-post] exists already, else create it
    	$tmp_id = $wpdb->get_var(
    		"SELECT id
    		  FROM $wpdb->posts
    		  WHERE post_type='page' AND
    		  post_status='publish' AND
    		 post_content LIKE '%[frontier-post]%'
    		");
    
    	if ( ((int)$tmp_id) <= 0)
    		{
    		// Add new page
    		$my_page = array(
                     'post_title' 		=> 'My Posts',
                     'post_content' 	=> '[frontier-post]',
                     'post_status' 		=> 'publish',
    				 'comment_status' 	=> 'closed',
                     'post_type' 		=> 'page',
    				);
    
    		// Insert the page into the database
            $tmp_id = wp_insert_post( $my_page );
    }
    	// save the page id so it can be reused in code and changed in settings
    	add_option("frontier_post_page_id", $tmp_id );

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.